結果
問題 |
No.153 石の山
|
ユーザー |
|
提出日時 | 2019-09-25 15:27:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 663 bytes |
コンパイル時間 | 605 ms |
コンパイル使用メモリ | 72,728 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 06:44:37 |
合計ジャッジ時間 | 1,538 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 14 WA * 13 |
ソースコード
#include<iostream> #include<set> using namespace std; int grundy[101] = {}; bool vis[101] = {}; int f(int x){ if(x == 1){ vis[x] = true; }else if(x == 2){ vis[x] = true; grundy[x] = 1; } if(vis[x]) return grundy[x]; vis[x] = true; set<int> s; s.insert(f(x/2)^f(x-x^2)); if(x%3 == 0) s.insert(f(x/3)^f(x/3)^f(x/3)); if(x%3 == 1) s.insert(f(x/3)^f(x/3)^f(x/3+1)); if(x%3 == 2) s.insert(f(x/3)^f(x/3+1)^f(x/3+1)); int num = 0; while(s.count(num)) num++; return grundy[x] = num; } int main(){ int n; cin >> n; cout << (f(n) == 0 ? 'B' : 'A') << endl; return 0; }