eolymp
bolt
Try our new interface for solving problems
Problems

Is it divisible by 3, 6 and 9?

published at 5/3/13, 7:30:20 am

Полагаю в Sample 2 должно быть 15

awpris replied:
Исправлено
published at 1/17/24, 11:59:28 pm

include <iostream>

include <string>

using namespace std;

int main() { string n;

cin >> n;

int t = n.length(), sum = 0;


for (char x : n) {
    sum += (x - 48);
}

cout << (sum % 3 == 0 ? "Yes\n" : "No\n");
cout << (sum % 3 == 0 && n[t - 1] % 2 == 0 ? "Yes\n" : "No\n");
cout << (sum % 9 == 0 ? "Yes\n" : "No\n");

return 0; }