結果

問題 No.7 プライムナンバーゲーム
ユーザー sawfish
提出日時 2022-10-17 05:25:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 773 bytes
コンパイル時間 614 ms
コンパイル使用メモリ 75,256 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-27 21:48:18
合計ジャッジ時間 1,266 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <vector>

using namespace std;
using LL = long long;

int main() {
    int N;
    cin >> N;

    vector<int> P;
    bool P_[N + 1];
    for (bool &i: P_) i = true;
    P_[0] = P_[1] = false;
    for (int i = 2; i <= sqrt(N); i++) {
        if (P_[i]) {
            for (int j = i * 2; j <= N; j += i) {
                P_[j] = false;
            }
            P.push_back(i);
        }
    }

    //
    bool WL[N + 2];
    WL[0] = WL[1] = true;
    WL[2] = WL[3] = false;
    for (int i = 4; i <= N; i++) {
        WL[i] = false;
        for (int p: P) {
            if (p <= i && !WL[i - p]) {
                WL[i] = true;
                break;
            }
        }
    }

    cout << (WL[N] ? "Win" : "Lose") << endl;
}
0