結果
問題 | No.7 プライムナンバーゲーム |
ユーザー | icchipost |
提出日時 | 2021-12-18 20:14:57 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 683 bytes |
コンパイル時間 | 1,477 ms |
コンパイル使用メモリ | 165,372 KB |
実行使用メモリ | 4,356 KB |
最終ジャッジ日時 | 2023-10-13 18:03:20 |
合計ジャッジ時間 | 4,002 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,352 KB |
testcase_01 | AC | 1 ms
4,352 KB |
testcase_02 | AC | 220 ms
4,352 KB |
testcase_03 | WA | - |
testcase_04 | AC | 4 ms
4,348 KB |
testcase_05 | WA | - |
testcase_06 | AC | 60 ms
4,356 KB |
testcase_07 | AC | 43 ms
4,352 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 42 ms
4,352 KB |
testcase_12 | AC | 158 ms
4,352 KB |
testcase_13 | AC | 170 ms
4,348 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | AC | 185 ms
4,352 KB |
ソースコード
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using pii = pair<int, int>; int main() { int n; cin >> n; vector<int> p(n + 1, 1); p[0] = p[1] = 0; for (int i = 2; i <= n; i++) { if (!p[i]) continue; for (int j = 2 * i; j <= n; j += i) { p[j] = 0; } } vector<int> dp(n + 1, -1); dp[2] = 0; for (int i = 2; i <= n; i++) { if (dp[i] == -1) continue; for (int j = 0; j <= n; j++) { if (!p[j]) continue; if (i + j <= n && dp[i + j] == -1) dp[i + j] = 1 - dp[i]; } } if (dp[2] == dp[n]) cout << "Lose" << endl; else cout << "Win" << endl; return 0; }