結果

問題 No.7 プライムナンバーゲーム
ユーザー tenkyu9
提出日時 2018-04-03 03:25:26
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 39 ms / 5,000 ms
コード長 713 bytes
コンパイル時間 559 ms
コンパイル使用メモリ 81,112 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-01 16:09:58
合計ジャッジ時間 1,371 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

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