結果
問題 |
No.7 プライムナンバーゲーム
|
ユーザー |
![]() |
提出日時 | 2024-07-20 11:03:25 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 14 ms / 5,000 ms |
コード長 | 479 bytes |
コンパイル時間 | 5,449 ms |
コンパイル使用メモリ | 277,308 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 11:03:32 |
合計ジャッジ時間 | 6,211 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int n;cin>>n; //素数列挙 vector<int> sosu(0); for(int i=2;i<=n;i++){ bool sos=true; for(int j:sosu){ if(i<j*j)break; if(i%j==0)sos=false; } if(sos)sosu.push_back(i); } vector<bool> dp(n+1,true); for(int i=2;i<=n;i++){ bool win=false; for(int j:sosu){ if(i<j)continue; if(!dp[i-j])win=true; } dp[i]=win; } cout<<(dp[n] ? "Win":"Lose")<<endl; }