結果
| 問題 | 
                            No.7 プライムナンバーゲーム
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-03-31 15:29:59 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 8 ms / 5,000 ms | 
| コード長 | 1,016 bytes | 
| コンパイル時間 | 1,502 ms | 
| コンパイル使用メモリ | 168,192 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-01 16:18:49 | 
| 合計ジャッジ時間 | 2,189 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 17 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;
typedef pair<int, int> P;
typedef struct{
  int first;
  int second;
  int third;
}T;
//昇順
bool comp_Se(T& l, T& r){
  return l.second < r.second;
}
vector<int> eratosthenes(int n){
  int i,j;
  vector<int> v(1,2);
  for(i=3;i<n+1;i+=2){
    v.push_back(i);
  }
  for(i=1;v[i]<=sqrt(n);i++){
    for(j=i+1;j<v.size();j++){
      if(!(v[j]%v[i])){
        v.erase(v.begin()+j);
        j--;
      }
    }
  }
  return v;
}
string res(bool b){
  if(b) return "Win";
  else return"Lose";
}
int main(void){
  int N;
  cin >> N;
  vector<int> v = eratosthenes(N);
  int i,j;
  //falseで負け,trueで勝ち
  vector<bool> game(2,true);
  game.push_back(false);
  game.push_back(false);
  for(i=4;i<=N;i++){
    bool g = false;
    for(j=0;j<v.size()&&v[j]<i;j++){
      if(!game[i-v[j]]){
        g = true;
        break;
      }
    }
    game.push_back(g);
  }
  cout << res(game[N]) << endl;
  return 0;
}