結果
| 問題 | No.7 プライムナンバーゲーム |
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2026-10-15 23:01:19 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 19 ms / 5,000 ms |
| + 86µs | |
| コード長 | 627 bytes |
| 記録 | |
| コンパイル時間 | 2,338 ms |
| コンパイル使用メモリ | 339,848 KB |
| 実行使用メモリ | 9,900 KB |
| 最終ジャッジ日時 | 2026-10-15 23:01:24 |
| 合計ジャッジ時間 | 4,154 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
vector<ll>isp(10009,1),primes;
isp[0]=isp[1]=0;
for(int i=2;i<10009;i++)
{
if(!isp[i])continue;
primes.push_back(i);
for(int j=i+i;j<10009;j+=i)isp[j]=0;
}
ll n;cin>>n;
vector<bool>dp(n+1,true);
for(int i=2;i<=n;i++)
{
dp[i]=false;
for(auto prime:primes)
{
if(i-prime<0)continue;
if(!dp[i-prime])dp[i]=true;
}
}
if(dp[n])cout<<"Win"<<endl;
else cout<<"Lose"<<endl;
}