結果

問題 No.7 プライムナンバーゲーム
ユーザー kotatsugamekotatsugame
提出日時 2017-09-19 00:58:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 386 bytes
コンパイル時間 475 ms
コンパイル使用メモリ 65,340 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-07 21:18:21
合計ジャッジ時間 4,048 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 152 ms
4,380 KB
testcase_01 AC 152 ms
4,376 KB
testcase_02 AC 152 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 152 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 152 ms
4,380 KB
testcase_08 AC 152 ms
4,376 KB
testcase_09 AC 152 ms
4,380 KB
testcase_10 WA -
testcase_11 AC 152 ms
4,380 KB
testcase_12 AC 152 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 152 ms
4,380 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;
		}
		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