Created
November 1, 2016 20:44
-
-
Save mmasztalerczuk/57b90e5893e7cc5aba11eae70b89ca44 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<cstring> | |
using namespace std; | |
class ThueMorseGame | |
{ | |
public: | |
string get(int n, int m) | |
{ | |
int last = 0; | |
int i = 0; | |
while (i <= n) | |
{ | |
if (__builtin_popcount(i)%2 == 1) | |
{ | |
i += 1; | |
} | |
else | |
{ | |
last = i; | |
i += m + 1; | |
} | |
} | |
return last == n ? "Bob" : "Alice"; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment