結果
| 問題 |
No.7 プライムナンバーゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-03-16 22:48:02 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 810 bytes |
| コンパイル時間 | 569 ms |
| コンパイル使用メモリ | 62,536 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-10-01 08:48:35 |
| 合計ジャッジ時間 | 1,173 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 17 |
ソースコード
#include <iostream>
#include <vector>
#include <queue>
std::vector<int> cul_prime() {
bool array[10001]{ false };
int sum = 0;
for (auto i = 2; i <= 10000; ++i) {
if (!array[i]) {
++sum;
for (auto j = 2; j <= 10000 / i; ++j) {
array[i * j] = true;
}
}
}
std::vector<int> res(sum);
int idx = 0;
for (auto i = 2; i <= 10000; ++i) {
if (!array[i]) res.at(idx++) = i;
}
return res;
}
int main() {
bool must_lose[10001]{ false };
must_lose[0] = true; must_lose[1] = true;
auto prime = cul_prime();
for (auto i = 0; i <= 10000; ++i) {
if (!must_lose[i]) {
for (auto j = 0; j < prime.size() && prime[j] <= 10000 - i; ++j) {
must_lose[i + prime[j]] = true;
}
}
}
int n;
std::cin >> n;
if (must_lose[n]) std::cout << "Lose\n";
else std::cout << "Win\n";
return 0;
}