intmain(){ int a, b, c; while (cin >> a >> b >> c) { bool ans = true; if (a + b != c) ans = false; for (int i = 0; i < 10; i++) { bucket[i] = 0; } for (int i = 0; i < 3; i++) { bucket[a % 10]++; a /= 10; bucket[b % 10]++; b /= 10; bucket[c % 10]++; c /= 10; } for (int i = 0; i < 10; i++) { if (bucket[i] > 1) { ans = false; break; } } if (bucket[0] > 0) ans = false; if (ans) cout << "YES!" << endl; else cout << "NO!" << endl; } }
boolisValidEquation(int a, int b, int c){ if (a + b != c) returnfalse; string combined = to_string(a) + to_string(b) + to_string(c); if (combined.length() != 9) returnfalse; set<char> digits(combined.begin(), combined.end()); return digits.size() == 9 && digits.count('0') == 0; }
intmain(){ int a, b, c; while (cin >> a >> b >> c) { if (isValidEquation(a, b, c)) { cout << "YES!" << endl; } else { cout << "NO!" << endl; } } return0; }