fork download
  1. #include <iostream>
  2. #include <cmath>
  3. #include <climits>
  4. #include <numeric>
  5. #include <algorithm>
  6. #include <map>
  7. #include <sstream>
  8. #include <string>
  9. #include <variant>
  10. #include <vector>
  11. #include <iomanip>
  12.  
  13. using namespace std;
  14.  
  15.  
  16. vector<string> split(const string& haystack, const string& needle) {
  17. vector<string> result;
  18. size_t start_pos = 0;
  19. size_t found_pos = haystack.find(needle, start_pos);
  20. while (found_pos != string::npos) {
  21. size_t count = found_pos - start_pos;
  22. string token = haystack.substr(start_pos, count);
  23. if (!token.empty()) {
  24. result.push_back(token);
  25. }
  26. start_pos = found_pos + needle.length();
  27. found_pos = haystack.find(needle, start_pos);
  28. }
  29. string last_token = haystack.substr(start_pos);
  30. if (!last_token.empty()) {
  31. result.push_back(last_token);
  32. }
  33. return result;
  34. }
  35.  
  36. int main() {
  37.  
  38. string s; cin >> s;
  39. int sum = 0;
  40. for (int i = 0; i < s.length(); i++) {
  41. sum = sum + (s[i] - '0');
  42. }
  43. int digit_root = -1;
  44. if (sum % 9 == 0 && sum != 0) {
  45. digit_root = 9;
  46. }
  47. else {
  48. digit_root = sum%9;
  49. }
  50. if (digit_root == 9) {
  51. cout << "YES";
  52. }
  53. else {
  54. cout << "NO";
  55. }
  56. return 0;
  57. }
  58.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
NO