結果

問題 No.7 プライムナンバーゲーム
ユーザー recososorecososo
提出日時 2020-02-11 13:26:08
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 132 ms / 5,000 ms
コード長 684 bytes
コンパイル時間 1,583 ms
コンパイル使用メモリ 166,160 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 04:49:16
合計ジャッジ時間 3,234 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,820 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 132 ms
6,944 KB
testcase_03 AC 8 ms
6,944 KB
testcase_04 AC 3 ms
6,944 KB
testcase_05 AC 3 ms
6,944 KB
testcase_06 AC 36 ms
6,948 KB
testcase_07 AC 24 ms
6,944 KB
testcase_08 AC 11 ms
6,948 KB
testcase_09 AC 56 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 24 ms
6,948 KB
testcase_12 AC 93 ms
6,948 KB
testcase_13 AC 99 ms
6,944 KB
testcase_14 AC 131 ms
6,944 KB
testcase_15 AC 125 ms
6,948 KB
testcase_16 AC 115 ms
6,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin >> n;
    vector<bool> p(n,true),w(n);
    p[0]=false;
    p[1]=false;
    for(int i=2;i*i<=n;i++){
        if(p[i]){
            for(int j=2;j*i<=n;j++){
                p[i*j]=false;
            }
        }
    }
    w[0]=true;
    w[1]=true;
    for(int i=0;i<=n;i++){
        for(int j=0;i+j<=n;j++){
            if(p[j]){
                if(w[i]){
                    w[i+j]=(w[i+j]|0);
                }
                else{
                    w[i+j]=true;
                }
            }
        }
    }
    if(w[n]){
        cout << "Win" << endl;
    }
    else{
        cout << "Lose" << endl;
    }
}
0