fork download
  1. /*
  2. * @Author: hungeazy
  3. * @Date: 2026-03-04 23:24:15
  4. * @Last Modified by: hungeazy
  5. * @Last Modified time: 2026-03-23 21:13:53
  6. */
  7. #include <bits/stdc++.h>
  8. using namespace std;
  9.  
  10. bool KTSNT(int n)
  11. {
  12. if (n < 2) return false;
  13. for (int i = 2; i <= sqrt(n); i++)
  14. if (n%i == 0) return false;
  15. return true;
  16. }
  17.  
  18. int main()
  19. {
  20. ios_base::sync_with_stdio(false);
  21. cin.tie(NULL); cout.tie(NULL);
  22. string s;
  23. cin >> s;
  24. int pos = s.find(','), sum = 0;
  25. for (int i = 0; i < s.size(); i++)
  26. if (isdigit(s[i]) == true)
  27. sum += s[i]-'0';
  28. if (KTSNT(sum) == false)
  29. {
  30. cout << "KHONG";
  31. return 0;
  32. }
  33. bool check = true;
  34. for (int i = 0; i <= pos-1; i++)
  35. if (KTSNT(s[i]-'0') == false)
  36. check = false;
  37. if (check == false)
  38. {
  39. check = true;
  40. for (int i = pos+1; i < s.size(); i++)
  41. if (KTSNT(s[i]-'0') == false)
  42. check = false;
  43. if (check == true) cout << "CO";
  44. else cout << "KHONG";
  45. }
  46. else cout << "CO";
  47. return 0;
  48. }
Success #stdin #stdout 0.01s 5324KB
stdin
Standard input is empty
stdout
KHONG