結果
問題 | No.7 プライムナンバーゲーム |
ユーザー |
![]() |
提出日時 | 2018-06-16 10:39:53 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 19 ms / 5,000 ms |
コード長 | 675 bytes |
コンパイル時間 | 1,107 ms |
コンパイル使用メモリ | 161,236 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-01 16:12:20 |
合計ジャッジ時間 | 1,747 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; int N; bool dp[10001] = {0}; bool pdp[10001]; vector<int> Prime(){ vector<int> ret; for (int i = 2; i < 10001; i++) { if (!pdp[i]){ ret.push_back(i); for (int j = i + i; j < 10001; j += i) { pdp[j] = true; } } } return ret; } int main(void){ cin >> N; auto v = Prime(); dp[0] = dp[1] = true; for(int i = 2; i <= N; ++i){ for(int j = 0; v[j] <= i && j < v.size(); ++j){ int p = i - v[j]; if(!dp[p]) dp[i] = true; } } if(dp[N]) cout << "Win" << endl; else cout << "Lose" << endl; return 0; }