結果

問題 No.7 プライムナンバーゲーム
ユーザー IrmystpIrmystp
提出日時 2014-11-29 20:05:36
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 872 bytes
コンパイル時間 1,092 ms
コンパイル使用メモリ 143,604 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-02 00:54:52
合計ジャッジ時間 2,047 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

bool isprime[10001];
int prime[5001];
int lim = 0;

void eratosthenes(void){
    fill(isprime, isprime+10001, true);
    isprime[0] = isprime[1] = false;
    for(int x = 2; x <= 10000; x++){
        if(isprime[x]){
            prime[lim++] = x;
            for(int y = x * x; y <= 10000; y += x) isprime[y] = false;
        }
    }
}

int N;
bool win[10001];

int main(){
    eratosthenes();
    scanf("%d", &N);
    fill(win, win+N+1, false);
    win[0] = win[1] = true;
    for(int x = 2; x <= N; x++){
        win[x] = false;
        for(int y = 0; prime[y] <= x; y++){
            if(!win[x-prime[y]]){
                win[x] = true;
                break;
            }
        }
    }
    if(win[N]){
        puts("Win");
    }else{
        puts("Lose");
    }
    return 0;
}
0