結果
問題 |
No.2 素因数ゲーム
|
ユーザー |
![]() |
提出日時 | 2020-06-22 16:56:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,162 bytes |
コンパイル時間 | 1,499 ms |
コンパイル使用メモリ | 172,360 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-03 18:42:36 |
合計ジャッジ時間 | 2,667 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 31 |
ソースコード
//c++ テンプレ #include<bits/stdc++.h> using namespace std; typedef long long llint; typedef long double ld; #define inf 1e18 #define mod 1000000007 priority_queue<llint,vector<llint>,greater<llint> > que; priority_queue<llint> Que; template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } vector<pair<long long, long long> > prime_factorize(long long N) { vector<pair<long long, long long> > res; for (long long a = 2; a * a <= N; ++a) { if (N % a != 0) continue; long long ex = 0; // 指数 // 割れる限り割り続ける while (N % a == 0) { ++ex; N /= a; } // その結果を push res.push_back({a, ex}); } // 最後に残った数について if (N != 1) res.push_back({N, 1}); return res; } void solve(){ llint n; cin >> n; vector<pair<llint,llint>>p= prime_factorize(n); llint x=p.size(); llint ans=0; for(int i=0;i<x;i++){ ans=ans^p[i].second; } if(ans==0) cout << "Bob" << endl; else cout << "Alice" << endl; } int main(){ solve(); return 0; }