結果

問題 No.7 プライムナンバーゲーム
ユーザー BantakoBantako
提出日時 2017-08-07 12:43:03
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 41 ms / 5,000 ms
コード長 624 bytes
コンパイル時間 1,368 ms
コンパイル使用メモリ 159,592 KB
実行使用メモリ 6,692 KB
最終ジャッジ日時 2024-04-09 04:22:43
合計ジャッジ時間 2,307 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,692 KB
testcase_01 AC 2 ms
6,688 KB
testcase_02 AC 40 ms
6,688 KB
testcase_03 AC 3 ms
6,692 KB
testcase_04 AC 2 ms
6,688 KB
testcase_05 AC 2 ms
6,688 KB
testcase_06 AC 11 ms
6,692 KB
testcase_07 AC 7 ms
6,692 KB
testcase_08 AC 3 ms
6,688 KB
testcase_09 AC 17 ms
6,688 KB
testcase_10 AC 1 ms
6,692 KB
testcase_11 AC 7 ms
6,692 KB
testcase_12 AC 28 ms
6,688 KB
testcase_13 AC 29 ms
6,688 KB
testcase_14 AC 41 ms
6,692 KB
testcase_15 AC 38 ms
6,688 KB
testcase_16 AC 35 ms
6,688 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
    8 | main(){
      | ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1000000007;
int prime[10001];//素数でないなら1
int win[10001];//勝てるなら1
main(){
    for(int i = 2;i*i <= 10000;i++){
        if(prime[i])continue;
        for(int j = i*2;j <= 10000;j+=i){
            prime[j] = 1;
        }
    }
    int N;
    cin >> N;
    for(int i = 4;i <= N;i++){
        for(int j = 2;j <= i-2;j++){
            if(!prime[j] && !win[i-j]){
                win[i] = 1;
                break;
            }
        }
    }
    if(win[N])cout << "Win" << endl;
    else cout << "Lose" << endl;
}
0