結果

問題 No.7 プライムナンバーゲーム
ユーザー mocobtmocobt
提出日時 2018-10-15 19:13:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 729 bytes
コンパイル時間 738 ms
コンパイル使用メモリ 79,308 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-20 20:29:31
合計ジャッジ時間 1,612 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <queue>
using namespace std;
#define MAX 10005

bool pdp[MAX];
vector<int> makeprime(int N){
    vector<int> ret;
    for(int i=2; i<=N; i++){
        if(pdp[i]) continue;
        ret.push_back(i);
        for(int j=i+i; j<MAX; j+=i) pdp[j] = true;
    }
    return ret;
}


int main(){
    int N;
    cin >> N;
    auto prime = makeprime(N);
    bool dp[N];
    dp[0] = dp[1] = true;
    for(int i=2; i<=N; i++){
        for(int j : prime){
            if(i-j<0) break;
            dp[i] |= !dp[i-j];
        }
    }
    if(dp[N]) cout << "Win" << endl;
    else cout << "Lose" << endl;
}
0