【題解】AtCoder ABC176B – Multiple of 9

【題目敘述】https://atcoder.jp/contests/abc176/tasks/abc176_b

#include <iostream>
using namespace std;

int tot;
string s;

int main() {
    cin >> s;
    for (int i = 0; i < s.length(); i++){
        tot += s[i]-'0';
    }
    if (tot % 9 == 0) cout << "Yes\n";
    else cout << "No\n";
}

分享本文 Share with friends