結果
| 問題 | No.2 素因数ゲーム |
| コンテスト | |
| ユーザー |
codershifth
|
| 提出日時 | 2015-07-12 17:42:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,191 bytes |
| コンパイル時間 | 1,940 ms |
| コンパイル使用メモリ | 167,016 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-26 11:35:18 |
| 合計ジャッジ時間 | 2,743 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int (i)=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RANGE(vec) (vec).begin(),(vec).end()
using namespace std;
template <typename T>
std::map<T,int> primeFactor(T n) {
std::map<T,int> res;
for (T i = 2; i*i <= n; ++i)
{
while (n%i==0)
{
++res[i];
n /= i;
}
}
if (n!= 1)
res[n] = 1;
return res;
}
class PrimeGame {
public:
// Nim に帰着できる
void solve(void) {
int N;
cin>>N;
auto primes = primeFactor(N);
vector<int> pows;
for (auto kv : primes)
pows.push_back(kv.second);
int x = 0;
REP(i, pows.size())
x ^= pows[i];
if (x)
cout<<"Alice"<<endl;
else
cout<<"Bob"<<endl;
}
};
#if 1
int main(int argc, char *argv[])
{
ios::sync_with_stdio(false);
auto obj = new PrimeGame();
obj->solve();
delete obj;
return 0;
}
#endif
codershifth