結果

問題 No.7 プライムナンバーゲーム
ユーザー karinohitokarinohito
提出日時 2022-01-11 11:22:57
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 827 bytes
コンパイル時間 1,811 ms
コンパイル使用メモリ 168,456 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 05:06:23
合計ジャッジ時間 2,734 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)


int main() {
    vll P;
    ll a=0;
    for(ll i=2;i<=10000;i++){
        bool C=true;
        for(ll j=2;j*j<=i;j++){
            a++;
            if(i%j==0){
                C=false;
                break;
            }
        }
        if(C){
            P.push_back(i);
        }
    }
    vector<bool> DP(10001,false);
    DP[0]=DP[1]=1;
    ll n=P.size();
    for(ll i=2;i<=10000;i++){
        bool C=false;
        rep(k,n){
            if(i<P[k])continue;
            if(!DP[i-P[k]]){
                C=true;
            }
        }
        if(C)DP[i]=true;
    }
    ll N;
    cin>>N;
    cout<<(DP[N]?"Win":"Lose")<<endl;
}
0