fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long int
  4. #define double long double
  5. #define print(a) for(auto x : a) cout << x << " "; cout << endl
  6.  
  7.  
  8. const int M = 1000000007;
  9. const int N = 3e5+9;
  10. const int INF = 2e9+1;
  11. const int LINF = 2000000000000000001;
  12.  
  13. inline int power(int a, int b, int mod=M) {
  14. int x = 1;
  15. a %= mod;
  16. while (b) {
  17. if (b & 1) x = (x * a) % mod;
  18. a = (a * a) % mod;
  19. b >>= 1;
  20. }
  21. return x;
  22. }
  23.  
  24.  
  25.  
  26. //_ ***************************** START Below *******************************
  27.  
  28. //* Change this to false => before submitting to cf
  29. // bool testing = true;
  30. bool testing = false;
  31.  
  32. vector<int> oddPrimes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};
  33.  
  34.  
  35. int toGuess;
  36.  
  37. void hack(){
  38. cin >> toGuess;
  39. }
  40.  
  41.  
  42. string interactor(int x){
  43. return toGuess % x == 0 ? "yes" : "no";
  44. }
  45.  
  46.  
  47.  
  48. string askQuery(int x){
  49. cout << x << endl;
  50.  
  51. if(testing){
  52. cout << interactor(x) << endl;
  53. return interactor(x);
  54. }
  55.  
  56. string isDivisor;
  57. cin >> isDivisor;
  58. return isDivisor;
  59. }
  60.  
  61.  
  62. string consistency(){
  63.  
  64. if(testing){
  65. hack();
  66. }
  67.  
  68.  
  69.  
  70. int q = 0;
  71. int ct = 0;
  72. string ans = "prime";
  73.  
  74. for(auto& p : oddPrimes){
  75. string res = askQuery(p);
  76. q++;
  77. if(res == "yes"){
  78. ct++;
  79. if(ct == 2){
  80. ans = "composite";
  81. break;
  82. }
  83.  
  84. if(p*p>50) continue;
  85. string res2 = askQuery(p*p);
  86. q++;
  87. if(res2 == "yes"){
  88. ans = "composite";
  89. break;
  90. }
  91. }
  92. }
  93.  
  94. if(testing) cout << "Max Queries : " << q << endl;
  95.  
  96. if(ans == "composite") return "composite";
  97.  
  98.  
  99. return ans;
  100.  
  101. }
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110. void solve() {
  111.  
  112. string ans = consistency();
  113. cout << ans << endl;
  114.  
  115. }
  116.  
  117.  
  118.  
  119.  
  120.  
  121. int32_t main() {
  122. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  123.  
  124. int t = 1;
  125. // cin >> t;
  126. while(t--){
  127. solve();
  128. }
  129.  
  130.  
  131. return 0;
  132. }
Success #stdin #stdout 0.01s 5320KB
stdin
94
stdout
2
yes
4
no
3
no
5
no
7
no
11
no
13
no
17
no
19
no
23
no
29
no
31
no
37
no
41
no
43
no
47
yes
Max Queries : 16
composite