結果

問題 No.7 プライムナンバーゲーム
ユーザー erieri
提出日時 2015-07-24 03:44:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 9 ms / 5,000 ms
コード長 549 bytes
コンパイル時間 459 ms
コンパイル使用メモリ 63,896 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-07-24 20:23:20
合計ジャッジ時間 1,338 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
bool pdp[10005];
vector<int> eratosthenes(){
	vector<int> v;
	for (int i = 2; i < 10005; i++)
	{
		if (pdp[i]) continue;
		v.push_back(i);
		for (int j = i + i; j < 10005; j += i){
			pdp[j] = true;
		}
	}
	return v;
}
bool dp[10005] = { true, true };
int main(){
	auto prime = eratosthenes();
	int n; cin >> n;
	for (int i = 2; i <= n; i++){
		for (int j: prime){
			if (i - j < 0) break;
			dp[i] |= !dp[i - j];
		}
	}
	cout << (dp[n] ? "Win" : "Lose") << endl;
	return 0;
}
0