結果
| 問題 |
No.7 プライムナンバーゲーム
|
| コンテスト | |
| ユーザー |
dekueue
|
| 提出日時 | 2017-02-11 12:36:35 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 19 ms / 5,000 ms |
| コード長 | 789 bytes |
| コンパイル時間 | 761 ms |
| コンパイル使用メモリ | 93,056 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-01 15:55:20 |
| 合計ジャッジ時間 | 1,581 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#include<numeric>
#include<algorithm>
#include<string>
#include<map>
#include<bitset>
#include<set>
#include<cmath>
#define int long long
const int inf=8938103643641919514ll;
const int mod=1000000007ll;
const int dd[]={0,-1,0,1,0};
using namespace std;
int pri[10001];
int ps;
int p[10001];
int saiki(int u){
if(u<2)
return true;
if(p[u]!=-1)
return p[u];
bool f=false;
for(int i=0;i<ps&&pri[i]<=u;i++){
f|=!saiki(u-pri[i]);
}
p[u]=f;
return f;
}
signed main(){
int n;
fill(p,p+10001,-1);
for(int i=2;i<10001;i++){
bool f=true;
for(int j=2;j*j<=i;j++){
if(i%j==0){
f=false;
break;
}
}
if(f)
pri[ps++]=i;
}
const char *wl[2]={"Lose","Win"};
cin>>n;
cout<<wl[saiki(n)]<<endl;
}
dekueue