結果

問題 No.7 プライムナンバーゲーム
ユーザー airuaiairuai
提出日時 2016-09-16 16:14:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 620 bytes
コンパイル時間 465 ms
コンパイル使用メモリ 55,620 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 04:03:08
合計ジャッジ時間 1,294 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>

int n;
int size;
int sosuu[2000];
bool dp[10001];
bool dpm[10001];

void setSosuu() {
	for (int i = 2; i <= n; ++i) {
		if (!dp[i]) {
			sosuu[size++] = i;
			for (int j = 0; j < n; j += i) {
				dp[j] = true;
			}
		}
	}
}

bool judge() {
	int t;
	for (int i = 2; i <= n; ++i) {
		for (int j = 0; j < size; ++j) {
			t = i - sosuu[j];
			if (t <= 1) {
				break;
			}
			else if (!dpm[t]) {
				dpm[i] = true;
				break;
			}
		}
	}
	
	return dpm[n];
}

int main() {
	std::cin >> n;
	setSosuu();
	if (judge()) {
		std::cout << "Win" << std::endl;
	}
	else {
		std::cout << "Lose" << std::endl;
	}
}
0