prestige

Untitled

Dec 7th, 2013
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <set>
  3. #include <vector>
  4. using namespace std;
  5. const int maxn = 1e+4;
  6. int n;
  7. int g[maxn];
  8. int mex(vector<int> &a) {
  9. set<int> b(a.begin(), a.end());
  10. for (int i = 0;;i++) {
  11. if(!b.count(i)) {
  12. return i;
  13. }
  14. }
  15. }
  16. void Grandi(int n) {
  17. vector<int> a;
  18. for (int i = 2; i < n; i++) {
  19. a.push_back(g[n - i - 1] ^ g[i - 2]);
  20. }
  21. a.push_back(g[n - 2]);
  22. g[n] = mex(a);
  23. }
  24. int main() {
  25. cin >> n;
  26. g[0] = 1;
  27. g[1] = 1;
  28. for (int i = 0; i <= 85; i++) {
  29. Grandi(i);
  30. }
  31. if(n <= 51) {
  32. if(g[n])
  33. cout << "White";
  34. else
  35. cout << "Black";
  36. }
  37. else {
  38. if(g[(n - 52) % 34 + 52])
  39. cout << "White";
  40. else
  41. cout << "Black";
  42. }
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment