結果

問題 No.7 プライムナンバーゲーム
ユーザー ryo ryoryo ryo
提出日時 2023-08-16 14:26:21
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 9 ms / 5,000 ms
コード長 294 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 29,260 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-16 14:26:22
合計ジャッジ時間 1,197 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main(){
	int p[1300]={},w[10001]={},n,s=0,i,j;
	
	scanf("%d",&n);
	
	for(i=2;i<=n;i++){
		for(j=0;p[j]&&i%p[j];j++);
		if(!p[j])p[s++]=i;
		
	}
	for(i=2;i<=n;i++){
		for(s=j=0;p[j]&&p[j]<=i;j++)s+=w[i-p[j]];
		w[i]=!s;
		
	}
	puts(w[n]?"Lose":"Win");
}
0