Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <set>
- #include <vector>
- using namespace std;
- const int maxn = 1e+4;
- int n;
- int g[maxn];
- int mex(vector<int> &a) {
- set<int> b(a.begin(), a.end());
- for (int i = 0;;i++) {
- if(!b.count(i)) {
- return i;
- }
- }
- }
- void Grandi(int n) {
- vector<int> a;
- for (int i = 2; i < n; i++) {
- a.push_back(g[n - i - 1] ^ g[i - 2]);
- }
- a.push_back(g[n - 2]);
- g[n] = mex(a);
- }
- int main() {
- cin >> n;
- g[0] = 1;
- g[1] = 1;
- for (int i = 0; i <= 85; i++) {
- Grandi(i);
- }
- if(n <= 51) {
- if(g[n])
- cout << "White";
- else
- cout << "Black";
- }
- else {
- if(g[(n - 52) % 34 + 52])
- cout << "White";
- else
- cout << "Black";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment