結果

問題 No.7 プライムナンバーゲーム
ユーザー kotatsugamekotatsugame
提出日時 2017-09-19 00:35:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 321 bytes
コンパイル時間 481 ms
コンパイル使用メモリ 65,048 KB
実行使用メモリ 13,888 KB
最終ジャッジ日時 2024-04-25 15:35:48
合計ジャッジ時間 6,911 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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