Link to problem:https://www.hackerrank.com/challenges/counter-game

The first solution is mine which isn’t being accepted while the second one is the AC solution.What’s the difference between them!!!

This is my solution

#include<bits/stdc++.h>

using namespace std;

int main()

{

unsigned long long int n,temp=0,count=0,p_count=0,winner=1;

int t;

scanf("%d",&t);

while(t–)

{

winner=1;

```
scanf("%llu",&n);
while(n!=1)
{
if((n&(n-1))==0) // n is a power of 2
{
n/=2;
}
else
{
n=n-pow(2,floor(log2(n)));
count++;
}
winner=!winner;
}
if(winner)
puts("Richard");
else
puts("Louise");
```

}

return 0;

}

The correct solution

#include<bits/stdc++.h>

using namespace std;

int main()

{

```
int t;
scanf("%d",&t);
while(t--)
{
unsigned long long n;
scanf("%llu",&n);
unsigned long long k ;
int winner = 1; //1 - richard 0 - louise
while(n!=1)
{
if( n && !(n&(n-1)))
n/=2;
else
{
k = pow(2,floor(log2(n)));
n-=k;
}
if(winner)
winner = 0;
else
winner = 1;
}
if(winner)
printf("Richard\n");
else
printf("Louise\n");
}
return 0;
```

}