結果
問題 | No.153 石の山 |
ユーザー |
|
提出日時 | 2015-02-17 22:34:32 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 873 bytes |
コンパイル時間 | 804 ms |
コンパイル使用メモリ | 97,388 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-14 14:30:29 |
合計ジャッジ時間 | 1,777 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 27 |
ソースコード
#include <cstdio> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <limits> #include <climits> #include <cfloat> #include <functional> using namespace std; int main() { int n; cin >> n; vector<int> grundy(n+1, 0); for(int i=2; i<=n; ++i){ set<int> s; s.insert(grundy[i/2] ^ grundy[(i+1)/2]); if(i >= 3) s.insert(grundy[i/3] ^ grundy[(i+1)/3] ^ grundy[(i+2)/3]); for(auto a : s){ if(grundy[i] != a) break; ++ grundy[i]; } } if(grundy[n] == 0) cout << 'B' << endl; else cout << 'A' << endl; return 0; }