結果
| 問題 |
No.7 プライムナンバーゲーム
|
| コンテスト | |
| ユーザー |
kongarishisyamo
|
| 提出日時 | 2016-02-24 17:44:08 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 806 bytes |
| コンパイル時間 | 606 ms |
| コンパイル使用メモリ | 61,752 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-22 13:23:34 |
| 合計ジャッジ時間 | 1,988 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 17 |
ソースコード
#include<iostream>
#include<vector>
using namespace std;
#define NMAX 10000
#define NO -1
#define WIN 0
#define LOSE 1
int main(){
int N;
bool hurui[NMAX+1];
vector<int> primenumber;
int winlose[NMAX+1];
for(int i=0;i<=NMAX;i++) hurui[i]=true;
hurui[0]=false;
hurui[1]=false;
for(int i=0;i<=NMAX;i++){
if(hurui[i]){
primenumber.push_back(i);
for(int j=i;j<NMAX;j+=i){
hurui[i]=false;
}
}
}
for(int i=0;i<=NMAX;i++) winlose[i]=NO;
winlose[2]=LOSE;
winlose[3]=LOSE;
for(int i=0;i<=NMAX;i++){
if(winlose[i]!=NO){
for(int j=0;j<primenumber.size();j++){
if(i+primenumber[j]>NMAX) break;
if(winlose[i+primenumber[j]]==WIN) continue;
winlose[i+primenumber[j]]=(winlose[i]==WIN)?LOSE:WIN;
}
}
}
cin>>N;
cout<<((winlose[N]==WIN)?"WIN":"LOSE")<<endl;
}
kongarishisyamo