結果

問題 No.7 プライムナンバーゲーム
ユーザー monnumonnu
提出日時 2020-05-30 20:04:55
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 830 bytes
コンパイル時間 1,793 ms
コンパイル使用メモリ 170,612 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-07 19:35:17
合計ジャッジ時間 3,123 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 RE -
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 5 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 6 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 4 ms
4,376 KB
testcase_12 AC 8 ms
4,376 KB
testcase_13 AC 9 ms
4,376 KB
testcase_14 RE -
testcase_15 AC 11 ms
4,376 KB
testcase_16 AC 10 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MOD 998244353
#define INF 1000000000

#define MAX 10000
vector<int> p;
vector<bool> p_table(MAX+1,true);
void prime(){
  p_table.at(0)=false,p_table.at(1)=false;
  for(int i=2;i<=MAX;i++){
    if(p_table.at(i)){
      p.push_back(i);
      for(int j=2;i*j<=MAX;j++){
        p_table.at(i*j)=false;
      }
    }
  }
}

int main(){
  int N;
  cin>>N;

  prime();
  vector<bool> can_win(N+1,true);
  for(int i=2;i<=N;i++){
    bool flag=false;
    for(int j=0;i-p.at(j)>=0;j++){
      if(can_win.at(i-p.at(j))==false){
        flag=true;
      }
    }
    if(flag){
      can_win.at(i)=true;
    }else{
      can_win.at(i)=false;
    }
  }

  if(can_win.at(N)){
    cout<<"Win"<<endl;
  }else{
    cout<<"Lose"<<endl;
  }

}
0