結果

問題 No.7 プライムナンバーゲーム
ユーザー eSeFeSeF
提出日時 2020-02-25 13:46:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 5,000 ms
コード長 493 bytes
コンパイル時間 2,161 ms
コンパイル使用メモリ 201,772 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-07-24 21:31:11
合計ジャッジ時間 2,802 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
bool dp[10101];
int main()
{
    int N;
    cin >> N;
    dp[0]=dp[1]=true;
    vector<int>p;
    for(int i=2;i<=10000;i++){
        bool ok=true;
        for(int j=2;j<=sqrt(i);j++){
            ok&=(i%j!=0);
        }
        if(ok)p.push_back(i);
    }
    for(int i=0;i<N;i++){
        for(int j:p){
            if(i+j<=N)dp[i+j]|=(!dp[i]);
        }
    }
    if(dp[N])cout << "Win";
    else cout << "Lose";
    cout << endl;
    return 0;
}
0