結果

問題 No.7 プライムナンバーゲーム
ユーザー kotatsugamekotatsugame
提出日時 2017-09-19 01:01:40
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 161 ms / 5,000 ms
コード長 388 bytes
コンパイル時間 490 ms
コンパイル使用メモリ 65,572 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 04:23:28
合計ジャッジ時間 4,085 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 160 ms
6,820 KB
testcase_01 AC 161 ms
6,944 KB
testcase_02 AC 158 ms
6,944 KB
testcase_03 AC 158 ms
6,948 KB
testcase_04 AC 159 ms
6,944 KB
testcase_05 AC 159 ms
6,948 KB
testcase_06 AC 158 ms
6,944 KB
testcase_07 AC 159 ms
6,944 KB
testcase_08 AC 158 ms
6,944 KB
testcase_09 AC 159 ms
6,944 KB
testcase_10 AC 159 ms
6,948 KB
testcase_11 AC 159 ms
6,948 KB
testcase_12 AC 160 ms
6,948 KB
testcase_13 AC 158 ms
6,944 KB
testcase_14 AC 158 ms
6,944 KB
testcase_15 AC 158 ms
6,944 KB
testcase_16 AC 158 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;
bool dp[10001];int p[10001],c;
int main()
{
	dp[0]=dp[1]=true;
	for(int i=2;i<=10000;i++)
	{
		bool flag=true;
		for(int j=2;j<i;j++)
		{
			flag&=i%j>0;
		}
		if(flag)p[c++]=i;
	}
	for(int i=2;i<=10000;i++)
	{
		bool flag=false;
		for(int j=0;j<c&&i-p[j]>=0;j++)flag|=!dp[i-p[j]];
		dp[i]=flag;
	}
	int n;cin>>n;cout<<(dp[n]?"Win":"Lose")<<endl;
}
0