結果
問題 | No.7 プライムナンバーゲーム |
ユーザー |
![]() |
提出日時 | 2023-10-07 17:53:30 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 15 ms / 5,000 ms |
コード長 | 807 bytes |
コンパイル時間 | 808 ms |
コンパイル使用メモリ | 107,332 KB |
最終ジャッジ日時 | 2025-02-17 06:10:22 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
#include<iostream>#include<iomanip>#include<string>#include<algorithm>#include<vector>#include<set>#include<list>#include<queue>#include<math.h>#include<bitset>using ll = long long;using namespace std;int main(){int n;cin >> n;vector<int> prime(n+1, 1), png(n+1, 0), p1;prime[0] = 0, prime[1] = 0;for (int i = 2; i <= pow(n, 0.5); i++){for (int j = i*i; j <= n; j += i){if(!(j%i)) prime[j] = 0;}}for (auto x : prime)if (n == 2 || n == 3) {cout << "Lose" << endl;return 0;}for (int i = 2; i <= n; i++){if (!(png[i])){for (int j = 2; j <= n-i; j++){if (prime[j]) png[i+j] = 1;}}}cout << ((png[n]) ? "Win" : "Lose") << endl;}