-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Bear_and_Prime_100.cpp
More file actions
139 lines (114 loc) · 3.14 KB
/
Copy pathA_Bear_and_Prime_100.cpp
File metadata and controls
139 lines (114 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#include <bits/stdc++.h>
using namespace std;
// Speed
#define ff() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
// Define
#define int long long int
#define db long double
#define vi vector<int>
#define vc vector<char>
#define pyes cout << "YES"<<'\n';
#define pno cout << "NO"<<'\n';
#define all(x) (x).begin(), (x).end()
#define MOD (int)(1e9 + 7)
#define MOD1 998244353
#define input(start, end, arr) { for(int i = start; i < end; ++i) cin >> arr[i]; }
#define f(i, x, n) for (int i = x; i < n; i++)
#define rf(i, x, n) for (int i = x; i >= n; i--)
#define sz(a) (int)a.size()
#define ppc __builtin_popcount
#define ppcll __builtin_popcountll
#define pi (3.141592653589)
#define INF 1e18
#define nl '\n'
#define sp " "
int mod_add(int a, int b, int m) { a = a % m; b = b % m; return (((a + b) % m) + m) % m; }
int mod_mul(int a, int b, int m) { a = a % m; b = b % m; return (((a * b) % m) + m) % m; }
int mod_sub(int a, int b, int m) { a = a % m; b = b % m; return (((a - b) % m) + m) % m; }
int expo(int a, int b, int mod) { int res = 1; while (b > 0) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b = b >> 1; } return res; }
vi primeFactorization(int n) {
vi factorization;
for (int d = 2; d * d <= n; d++) {
while (n % d == 0) {
factorization.push_back(d);
n /= d;
}
}
if (n > 1) {
factorization.push_back(n);
}
return factorization;
}
vi sieve(int limit) {
vi primes;
vector<bool> is_prime(limit + 1, true);
is_prime[0] = is_prime[1] = false;
for (int i = 2; i <= limit; i++) {
if (is_prime[i]) {
primes.push_back(i);
for (int j = i * i; j <= limit; j += i) {
is_prime[j] = false;
}
}
}
return primes;
}
string getBinary(int n) {
bitset<8> b(n);
return b.to_string();
}
int maxSubarraySum(int arr[], int n) {
int maxi = INT_MIN;
int sum = 0;
for (int i = 0; i < n; i++) {
sum += arr[i];
if (sum > maxi) {
maxi = sum;
}
if (sum < 0) {
sum = 0;
}
}
return maxi;
}
// bool check(db mid,vector<db>&a,int n,int k){
// db cnt = 0;
// for(int i=0; i < k; i++){
// cnt += a[i];
// }
// return cnt >= 0;
// }
void solve() {
/*
Interactive is the thing which makes the question a 1400 rated
They will give have a hidden number with them and we should find
if it is prime or composite
if a number is composite it should multiple of two primes
given that the number willl be between 2 to 100
so thte possible prime arre 2 3 5 7 11 13 17 19 23 29 31 41 43 47
edge cases like 25 4
*/
vi a = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47,4,9,25,49};
string verdict;
int cnt =0;
for(auto &it : a){
cout<<it<<endl;
cin>>verdict;
if(verdict == "yes")cnt++;
if(cnt > 1){
cout<< "composite"<<endl;
return;
}
}
cout<<"prime"<<endl;
}
int32_t main() {
ff();
int tc;
// cin >> tc;
tc = 1;
while (tc--) {
solve();
}
return 0;
}