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-11 23:03:10
  6. */
  7. #include <bits/stdc++.h>
  8. using namespace std;
  9. string s;
  10.  
  11. bool KTSNT(int n)
  12. {
  13. if (n < 2) return false;
  14. for (int i = 2; i <= sqrt(n); i++)
  15. if (n%i == 0) return false;
  16. return true;
  17. }
  18.  
  19. int main()
  20. {
  21. ios_base::sync_with_stdio(false);
  22. cin.tie(NULL); cout.tie(NULL);
  23. cin >> s;
  24. int n = s.size(), sum = 0, pos = -1;
  25. bool check = true;
  26. for (int i = 0; i < n; i++)
  27. if (s[i] == ',') pos = i;
  28. else sum += s[i]-'0';
  29. for (int i = 0; i < n; i++)
  30. {
  31. if (s[i] == ',') break;
  32. int c = s[i]-'0';
  33. if (!KTSNT(c))
  34. {
  35. check = false;
  36. break;
  37. }
  38. }
  39. if (!KTSNT(sum))
  40. {
  41. cout << "KHONG";
  42. return 0;
  43. }
  44. if (check and KTSNT(sum))
  45. {
  46. cout << "CO";
  47. return 0;
  48. }
  49. check = true;
  50. for (int i = pos+1; i < n; i++)
  51. {
  52. int c = s[i]-'0';
  53. if (!KTSNT(c))
  54. {
  55. check = false;
  56. break;
  57. }
  58. }
  59. if (check and KTSNT(sum)) cout << "CO";
  60. else cout << "KHONG";
  61. return 0;
  62. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
KHONG