結果
問題 | No.7 プライムナンバーゲーム |
ユーザー |
![]() |
提出日時 | 2017-01-27 22:14:00 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 12 ms / 5,000 ms |
コード長 | 909 bytes |
コンパイル時間 | 1,200 ms |
コンパイル使用メモリ | 161,516 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-01 15:55:11 |
合計ジャッジ時間 | 1,905 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<ll> VL; typedef vector<VL> VVL; typedef pair<int, int> PII; #define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(x) x.begin(), x.end() #define MOD 1000000007 #define INF 1000000000 #define PI 3.14159265359 #define EPS 1e-12 bool pdp[10010]; int dp[10010]; vector<int> prime(){ vector<int> ret; for (int i = 2; i < 10010; i++) { if (pdp[i]) continue; ret.push_back(i); for (int j = i + i; j < 10010; j += i) { pdp[j] = true; } } return ret; } int main(void) { int n; cin >> n; auto p = prime(); dp[0] = dp[1] = true; FOR(i, 2, n+1) { for(int j: p) { if(i - j < 0) break; dp[i] |= !dp[i-j]; } } if(dp[n]) cout << "Win" << endl; else cout << "Lose" << endl; return 0; }