結果
問題 |
No.2 素因数ゲーム
|
ユーザー |
![]() |
提出日時 | 2015-02-10 23:54:43 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 59 ms / 5,000 ms |
コード長 | 755 bytes |
コンパイル時間 | 1,114 ms |
コンパイル使用メモリ | 77,708 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-26 10:57:59 |
合計ジャッジ時間 | 2,367 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 31 |
ソースコード
#include <iostream> #include <map> using namespace std; map<map<int, int>, int> memo; int win(map<int, int>& f) { if (f.size()==1) return 1; if (memo.count(f)) return memo[f]; int res=0; auto x=f; for(auto& v: f) { for(int i=1;i<v.second;++i) { --x[v.first]; res=res or !win(x); } x.erase(v.first); res=res or !win(x); x[v.first]=v.second; } return res; } int main() { int n; while (cin>>n) { map<int, int> f; for(int i=2;i*i<=n;++i) { int c=0; while (n%i==0) { ++c; n/=i; } if (c) f[i]=c; } if (n>1) f[n]++; memo.clear(); cout<<(win(f)? "Alice" : "Bob")<<endl; } }