結果

問題 No.7 プライムナンバーゲーム
ユーザー ryo ryoryo ryo
提出日時 2023-08-16 16:26:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 332 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 32,264 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-16 16:26:09
合計ジャッジ時間 1,119 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 9 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 5 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 6 ms
4,376 KB
testcase_13 AC 6 ms
4,380 KB
testcase_14 AC 8 ms
4,376 KB
testcase_15 AC 8 ms
4,376 KB
testcase_16 AC 7 ms
4,380 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(int i=0;i<=n;i++)printf("%d ",p[i]);
	for(i=2;i<=n;i++){
		for(s=j=0;p[j]<=i;j++)s+=w[i-p[j]];
		w[i]=!s;
		
	}
	puts(w[n]?"Lose":"Win");
}
0