結果
問題 | No.103 素因数ゲーム リターンズ |
ユーザー |
![]() |
提出日時 | 2015-03-04 16:14:56 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 14 ms / 5,000 ms |
コード長 | 915 bytes |
コンパイル時間 | 1,562 ms |
コンパイル使用メモリ | 170,684 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-24 01:23:31 |
合計ジャッジ時間 | 2,463 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> P; typedef pair<int,pair<int,int>> PP; typedef long long ll; const double EPS = 1e-8; const int INF = 1e9; const int MOD = 1e9+7; int dy[] = {0,1,0,-1}; int dx[] = {1,0,-1,0}; map<int,int>prime_factor(int n){ map<int,int>res; for(int i=2;i*i<=n;i++){ while(n%i==0){ ++res[i]; n /= i; } } if(n!=1)res[n]=1; return res; } int grundy(int x){ set<int> s; map<int,int> fact = prime_factor(x); for(auto it = fact.begin();it != fact.end();it++){ s.insert(grundy(x / it->first)); if(it->second >= 2)s.insert(grundy(x / (it->first*it->first))); } int res = 0; while(s.count(res))res++; return res; } int main(void) { int n; cin >> n; vector<int> m(n); for(int i=0;i<n;i++){ cin >> m[i]; } int res = 0; for(int i=0;i<n;i++){ res ^= grundy(m[i]); } cout << (res == 0 ? "Bob" : "Alice") << endl; return 0; }