結果

問題 No.7 プライムナンバーゲーム
ユーザー Im_GimletIm_Gimlet
提出日時 2020-07-22 13:47:44
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,504 bytes
コンパイル時間 1,624 ms
コンパイル使用メモリ 168,448 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-02 11:10:08
合計ジャッジ時間 2,480 ms
ジャッジサーバーID
(参考情報)
judge16 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

// Eratosthenesの篩
vector<bool> primeno(100010, true);
void Eratosthenes(int n) {
    primeno.at(0) = primeno.at(1) = false;
    int limit = sqrt(n);
    for(int i = 2; i < limit; ++i) {
        if(primeno.at(i)) {
            for(int j = 0; i*(j+2) < n; ++j) {
                primeno.at(i*(j+2)) = false;
            }
        }
    }
}

int n;

int main() {
    cin >> n;
    Eratosthenes(10010);
    vector<int> check(10010, -1);
    check[0] = check[1] = 0;
    check[2] = check[3] = 0;
    for(int i = 2; i <= 3; ++i) {
        for(int j = 2; j <= n; ++j) {
            if(primeno[j]) {
                if(check[i+j] == -1) {
                    if(check[i] == 0) check[i+j] = 1;
                    else check[i+j] = 0;
                }
            }
        }
    }

    for(int i = 2; i <= n; ++i) {
        for(int j = 2; j <= 3; ++j) {
            if(check[i+j] == -1) {
                if(check[i] == 0) check[i+j] = 1;
                else check[i+j] = 0;
            }
        }
    }

    if(check[n] == 0) cout << "Lose" << endl;
    else cout << "Win" << endl;
}
0