結果
| 問題 |
No.7 プライムナンバーゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-09-27 18:08:15 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,013 bytes |
| コンパイル時間 | 3,783 ms |
| コンパイル使用メモリ | 318,372 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-27 18:08:21 |
| 合計ジャッジ時間 | 5,248 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 WA * 5 |
ソースコード
#include <bits/stdc++.h>
using i64 = long long;
std::vector<int> p;
int fact = []() {
constexpr int n = 1e5;
std::vector<int> st(n + 1, 0);
st[0] = st[1] = 1;
for (int i = 2; i <= n; ++i) {
if (!st[i]) {
p.push_back(i);
}
for (auto &pi : p) {
if (1LL * i * pi > n) break;
st[i * pi] = 1;
if (i % pi == 0) break;
}
}
return 0;
}();
int main() {
std::cin.tie(nullptr)->sync_with_stdio(false);
i64 n;
std::cin >> n;
std::vector<int> dp(n + 1, -2);
const int m = p.size();
dp[0] = dp[1] = 1;
for (int i = 0; i < m; ++i) {
for (int j = n; j >= 0; --j) {
if (j - p[i] >= 0 && dp[j - p[i]] == 1) {
dp[j] = std::max(dp[j], -1);
}
if (j - p[i] >= 0 && dp[j - p[i]] == -1) {
dp[j] = std::max(dp[j], 1);
}
}
}
std::cout << (dp[n] == 1 ? "Win" : "Lose") << '\n';
return 0;
}