結果

問題 No.2 素因数ゲーム
ユーザー A8pfA8pf
提出日時 2018-10-02 14:46:08
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,125 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 64,620 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-20 14:29:28
合計ジャッジ時間 1,252 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 1 ms
5,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 WA -
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
5,376 KB
testcase_29 WA -
testcase_30 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0