結果

問題 No.7 プライムナンバーゲーム
ユーザー tenkyu9tenkyu9
提出日時 2018-04-03 03:22:07
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 732 bytes
コンパイル時間 541 ms
コンパイル使用メモリ 76,280 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-08 13:55:43
合計ジャッジ時間 1,430 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;

int main(){

	int n;
	cin >> n;
	bool flag[10100];
	memset(flag, 1, 10100);
	int num=2;
	while(num<110){
		if(flag[num]){
			for(int i=2; i<10100/num; i++){
				flag[num*i]=false;
			}
		}
		num++;
	}

	bool dp[10001]={false};
	dp[0]=dp[1]=true;
	for(int i=2; i<=n; i++){
		for(int j=2; j<=i; i++){
			if(flag[j]){
				if(i-j>=2 && !dp[i-j]){
					dp[i]=true;
					break;
				}
			}
		}
	}
	if(dp[n]){
		cout << "Win" << endl;
	} else {
		cout << "Lose" << endl;
	}

	return 0;
}
0