-
Notifications
You must be signed in to change notification settings - Fork 0
/
bool.cpp
52 lines (46 loc) · 733 Bytes
/
bool.cpp
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
#include <bits/stdc++.h>
using namespace std;
typedef long l;
bool poweroftwo(long n){
int count=0;
while(n){
count+=n&1;
n=n>>1;
}
return count==1;
}
// Complete the counterGame function below.
string counterGame(l n) {
int max=-32767,x=1,i=0;
while(n>1){
if(poweroftwo(n)){
n/=2;
}
else{
while(x<n){
if(max<x)
{
max=x;
x=x<<1;
}
}
n=n-max;
}
i++;
}
if(i%2==0)
return "Louise";
else
return "Richard";
}
int main()
{
ofstream fout(getenv("OUTPUT_PATH"));
int n,t;
cin >> t;
for(int i=0;i<t;i++){
cin>>n;
cout<<poweroftwo(n);
}
return 0;
}