結果
| 問題 | No.2 素因数ゲーム |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-10-02 14:46:08 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,125 bytes |
| コンパイル時間 | 614 ms |
| コンパイル使用メモリ | 64,744 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-12 10:03:08 |
| 合計ジャッジ時間 | 1,523 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 WA * 10 |
ソースコード
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
bool dp[5000][5000];//dp[1個しかない素因数][2個以上ある素因数]=先手が勝つかどうか
int main()
{
ll n;
int ans=0;
cin>>n;
ll k=n;
int c1=0;
int c2=0;
int cnt=0;
while(k%2==0)
{
k/=2;
cnt++;
}
if(cnt==1)
c1++;
else if(cnt>1)
c2++;
for(int i=3;i<11000;i+=2)
{
if(k==1)
break;
cnt=0;
while(k%i==0)
{
k/=i;
cnt++;
}
if(cnt==1)
c1++;
else if(cnt>1)
c2++;
}
if(k!=1)
c1++;//でかい素数の分
//ここからdp
dp[0][0]=false;
dp[1][0]=true;
dp[0][1]=true;
for(int i=2;i<c1+1;i++)
dp[i][0]=!dp[i-1][0];
for(int i=1;i<c2+1;i++)
{
for(int j=1;j<c1+1;j++)
{
//c1を1つ使う場合
bool f1=!dp[i-1][j];
//c2をすべて使う場合
bool f2=!dp[i][j-1];
//c2を一つ残して使う場合
bool f3=!dp[i+1][j-1];
dp[i][j]=(f1||f2||f3);
}
}
//cerr<<c1<<" "<<c2<<endl;
if(dp[c1][c2])
cout<<"Alice"<<endl;
else
cout<<"Bob"<<endl;
return 0;
}