結果

問題 No.7 プライムナンバーゲーム
ユーザー yuho0819yuho0819
提出日時 2016-09-03 14:44:58
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 657 bytes
コンパイル時間 134 ms
コンパイル使用メモリ 23,680 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-27 15:20:38
合計ジャッジ時間 842 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
6,816 KB
testcase_01 AC 7 ms
6,940 KB
testcase_02 AC 6 ms
6,944 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 7 ms
6,944 KB
testcase_06 AC 7 ms
6,940 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 7 ms
6,944 KB
testcase_10 WA -
testcase_11 AC 7 ms
6,940 KB
testcase_12 WA -
testcase_13 AC 7 ms
6,940 KB
testcase_14 AC 7 ms
6,944 KB
testcase_15 AC 7 ms
6,940 KB
testcase_16 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:30:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |         scanf("%d",&a);
      |         ~~~~~^~~~~~~~~
main.cpp:8:21: warning: iteration 9999 invokes undefined behavior [-Waggressive-loop-optimizations]
    8 |                 k[i]=0;
      |                 ~~~~^~
main.cpp:6:18: note: within this loop
    6 |         for(i=1;i<=10000;i++){
      |                 ~^~~~~~~

ソースコード

diff #

#include<stdio.h>
int main(void)
{
	int a,s,d,f,g,h[10001],i,j,k[10000];
	s=2;
	for(i=1;i<=10000;i++){
		h[i]=0;
		k[i]=0;
	}
	k[2]=-1;
	k[3]=-1;
	h[2]=0;	
	for(i=2;i<10000;i++){
		if(h[i]==0){
			for(j=2;j<=5000;j++){
				if(i*j<=10000)
					h[i*j]=1;
			}
		}
	}
	/*for(i=1;i<=2252;i++){
		printf("%d,%d\n",i,h[i]);
	}*/
	/*for(i=1;i<=10000;i++){
		if(h[i]==1){
			k[3+i]=1;
			k[2+i]=1;
		}
	}*/
	scanf("%d",&a);
	while(1){
		if(a==2||a==3)
			break;
		if(s==2)
			s=1;
		else
			s=2;
		for(i=a-1;i>1;i--){
			if(a-i>1){
				if(h[i]==0){
					a-=i;
					break;
				}
			}
		}
	}
		if(s==2)
			printf("Lose\n");
		if(s==1)
			printf("Win\n");
	return 0;
}
0