結果

問題 No.7 プライムナンバーゲーム
ユーザー tenkyu9tenkyu9
提出日時 2018-04-03 03:25:26
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 46 ms / 5,000 ms
コード長 713 bytes
コンパイル時間 602 ms
コンパイル使用メモリ 81,356 KB
実行使用メモリ 6,696 KB
最終ジャッジ日時 2024-04-09 04:27:02
合計ジャッジ時間 1,655 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,692 KB
testcase_01 AC 2 ms
6,692 KB
testcase_02 AC 46 ms
6,692 KB
testcase_03 AC 4 ms
6,688 KB
testcase_04 AC 2 ms
6,688 KB
testcase_05 AC 2 ms
6,688 KB
testcase_06 AC 13 ms
6,692 KB
testcase_07 AC 9 ms
6,688 KB
testcase_08 AC 4 ms
6,688 KB
testcase_09 AC 21 ms
6,692 KB
testcase_10 AC 2 ms
6,692 KB
testcase_11 AC 9 ms
6,692 KB
testcase_12 AC 33 ms
6,692 KB
testcase_13 AC 35 ms
6,696 KB
testcase_14 AC 46 ms
6,696 KB
testcase_15 AC 44 ms
6,688 KB
testcase_16 AC 41 ms
6,692 KB
権限があれば一括ダウンロードができます

ソースコード

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};
	for(int i=2; i<=n; i++){
		for(int j=2; j<=i; j++){
			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