結果

問題 No.7 プライムナンバーゲーム
ユーザー TwizzTwizz
提出日時 2017-05-05 23:49:07
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 644 bytes
コンパイル時間 1,274 ms
コンパイル使用メモリ 146,380 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-10-12 10:32:33
合計ジャッジ時間 2,277 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include"bits/stdc++.h"
//#include<bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
//const int mod = 1e9 + 7;

int sos[10002];
int dp[10002];


vector<int> so(int n){
	vector<int> ret;
	rep(i, 2, n + 1) {
		if (sos[i])continue;
		ret.push_back(i);
		for (int j = i * 2; j <= n; j += i) {
			sos[j] = 1;
		}
	}
	return ret;
}

int main() {
	int n;
	cin >> n;
	auto prime = so(n);
	dp[0] = 1; dp[1] = 1;
	rep(i, 2, n) {
		for (int j : prime) {
			if (i - j < 0)break;
			dp[i] |= !dp[i - j];
		}
	}
	if (dp[n]){print("Win");}
	else { print("Lose"); }
	return 0;
}
0