-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCounterGame.cpp
More file actions
58 lines (49 loc) · 888 Bytes
/
CounterGame.cpp
File metadata and controls
58 lines (49 loc) · 888 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
51
52
53
54
55
56
57
58
#include <bits/stdc++.h>
using namespace std;
// Complete the counterGame function below.
string counterGame(long n)
{
long i,k;
int c=0;
while(1)
{
for(i=0;;i++)
{
k = pow(2,i);
if(n==k)
{
n/=2;
c=1-c;
break;
}
if(k>n)
{
n = n - k/2;
c=1-c;
break;
}
}
if(n==1)
break;
}
if(c==1)
return "Louise";
else
return "Richard";
}
int main()
{
ofstream fout(getenv("OUTPUT_PATH"));
int t;
cin >> t;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
for (int t_itr = 0; t_itr < t; t_itr++) {
long n;
cin >> n;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
string result = counterGame(n);
fout << result << "\n";
}
fout.close();
return 0;
}