結果

問題 No.7 プライムナンバーゲーム
ユーザー otamay6otamay6
提出日時 2019-10-17 17:10:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 645 bytes
コンパイル時間 1,552 ms
コンパイル使用メモリ 168,876 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-07-24 21:25:14
合計ジャッジ時間 2,340 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    int N;cin>>N;
    vector<int> p;
    vector<bool> sieve(N+1,true);
    rep(i,2,N+1){
        if(sieve[i]){
            REP(j,N/i+1) sieve[i*j]=false;
            p.push_back(i);
        }
    }
    vector<int> win(N+1,0);
    rep(i,2,N+1){
        if(win[i]==0) REP(j,p.size()){
            if(p[j]+i>N) break;
            win[p[j]+i]=1;
        }
    }
    if(win[N]) cout<<"Win"<<endl;
    else cout<<"Lose"<<endl;
}
0