結果
| 問題 |
No.7 プライムナンバーゲーム
|
| コンテスト | |
| ユーザー |
eSeF
|
| 提出日時 | 2020-02-25 13:46:25 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 23 ms / 5,000 ms |
| コード長 | 493 bytes |
| コンパイル時間 | 2,062 ms |
| コンパイル使用メモリ | 196,228 KB |
| 最終ジャッジ日時 | 2025-01-09 02:11:52 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
bool dp[10101];
int main()
{
int N;
cin >> N;
dp[0]=dp[1]=true;
vector<int>p;
for(int i=2;i<=10000;i++){
bool ok=true;
for(int j=2;j<=sqrt(i);j++){
ok&=(i%j!=0);
}
if(ok)p.push_back(i);
}
for(int i=0;i<N;i++){
for(int j:p){
if(i+j<=N)dp[i+j]|=(!dp[i]);
}
}
if(dp[N])cout << "Win";
else cout << "Lose";
cout << endl;
return 0;
}
eSeF