-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrime_Game.cpp
More file actions
50 lines (46 loc) · 965 Bytes
/
Prime_Game.cpp
File metadata and controls
50 lines (46 loc) · 965 Bytes
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
/*
* @Date : 2021-02-07 01:48:02
* @Author : aerma7309
*/
#include <bits/stdc++.h>
using namespace std;
int FastIO = []() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
return 0;
}();
const int mxn = 1e6;
vector<int> primes;
void makeSieve()
{
bitset<mxn> sieve(0);
for (int i = 3; i < sqrt(mxn) + 1; i += 2)
if (not sieve[i])
for (int j = i * i; j < mxn; j += i)
sieve[j] = true;
primes.push_back(2);
for (int i = 3; i < mxn; i += 2)
if (not sieve[i])
primes.push_back(i);
}
void solve()
{
int x, y, p;
cin >> x >> y;
auto it = upper_bound(primes.begin(), primes.end(), x);
if (it == primes.begin())
p = 0;
else
p = (--it - primes.begin());
cout << (p < y ? "Chef" : "Divyam") << '\n';
}
signed main()
{
makeSieve();
int t;
cin >> t;
while (t--)
solve();
return 0;
}