题解 | #小红的三倍数#看没人水一篇

小红的三倍数

https://ac.nowcoder.com/acm/problem/275612

#include<bits/stdc++.h>
using namespace std;
int comput(const string& num){
    int sum = 0;
    for(char digit:num){
        sum += digit- '0';  
    }
    return sum;
}
int main(){
    int n;
    cin>>n;
    int total = 0;
    string nums;
    while(n--){
        cin>>nums;
        total += comput(nums);
    }
    cout << (total % 3 == 0 ? "YES" : "NO") << endl;
    return 0;
}
全部评论

相关推荐

06-10 23:36
已编辑
首都经济贸易大学 C++
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务