結果

問題 No.7 プライムナンバーゲーム
ユーザー ryo ryoryo ryo
提出日時 2023-08-17 15:10:30
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 15 ms / 5,000 ms
コード長 666 bytes
コンパイル時間 1,067 ms
コンパイル使用メモリ 28,676 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-17 15:10:32
合計ジャッジ時間 2,157 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>

int main(){
    
    int n;
    scanf("%d",&n);
    
    int p[100001];
    int data[100001]={};
    int num=0;
    
    for(int i=2;i<=n;i++){
        
        if(data[i]==0){
            p[num]=i;
            num++;
            for(int j=i*2;j<=n;j+=i)data[j]=1;
        }
    }
    //for(int i=0;i<num;i++)printf("%d ",p[i]);
    
    int w[100001]={};
    
    for(int i=2;i<=n;i++){
        int s=0;
        for(int j=0;j<num;j++){
            if(i-p[j] < 0)continue;
            s+=w[i-p[j]];
        }
        w[i]=!s;
    }
    
    
    if(w[n]==0){
        printf("Win");
    }
    else printf("Lose");
    return 0;
}
0