結果
問題 | No.7 プライムナンバーゲーム |
ユーザー |
![]() |
提出日時 | 2020-02-12 18:59:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 5,000 ms |
コード長 | 792 bytes |
コンパイル時間 | 847 ms |
コンパイル使用メモリ | 74,036 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-01 16:30:45 |
合計ジャッジ時間 | 1,387 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
#include <iostream> #include <vector> #include <queue> using namespace std; const int INF = 1145141919; int main() { vector<bool> isPrime(10010, true); vector<int> prime; isPrime[0] = false, isPrime[1] = false; for (int i = 2; i <= 10000; i++) { if (isPrime[i]) { prime.push_back(i); for (int j = i * i; j <= 10000; j += i)isPrime[j] = false; } } vector<bool> dp(10010, true); for (int i = 2; i <= 10000; i++) { bool found = false; for (auto x:prime) { if (x > i)break; if (!dp[i - x]) { found = true; break; } } dp[i] = found; } int n; cin >> n; cout << (dp[n] ? "Win" : "Lose") << endl; return 0; }