結果
問題 | No.153 石の山 |
ユーザー |
![]() |
提出日時 | 2016-07-09 02:32:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,451 bytes |
コンパイル時間 | 1,773 ms |
コンパイル使用メモリ | 178,788 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-14 14:04:31 |
合計ジャッジ時間 | 2,675 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 18 WA * 9 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,x,y) for(int i=(x);i<(y);++i) #define debug(x) #x << "=" << (x) #ifdef DEBUG #define _GLIBCXX_DEBUG #define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl #else #define show(x) #endif typedef long long int ll; typedef pair<int,int> pii; template<typename T> using vec=std::vector<T>; const int inf=1<<30; const long long int infll=1LL<<62; const double eps=1e-9; const int dx[]={1,0,-1,0},dy[]={0,1,0,-1}; template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (const auto &v : vec) { os << v << ","; } os << "]"; return os; } void solve(){ vector<int> memo(101); vector<bool> done(101); memo[1]=0; done[1]=true; function<int(int)> grundy=[&](int x){ auto &res=memo[x]; if(done[x]) return res; done[x]=true; set<int> s; if(x%2==0) s.insert(0); else s.insert(grundy(x/2)^grundy(x/2+1)); if(x%3==0) s.insert(grundy(x/3)); else if(x%3==1) s.insert(grundy(x/3+1)); else s.insert(grundy(x/3)); while(s.count(res)!=0) ++res; return res; }; int n; cin >> n; if(grundy(n)) cout << "A" << endl; else cout << "B" << endl; } int main(){ std::cin.tie(0); std::ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(10); solve(); return 0; }