結果

問題 No.7 プライムナンバーゲーム
ユーザー kapokapo
提出日時 2016-04-28 12:56:46
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 503 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 23,528 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 05:10:41
合計ジャッジ時間 5,115 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 245 ms
5,248 KB
testcase_01 AC 244 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 250 ms
5,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 244 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 253 ms
5,376 KB
testcase_15 AC 245 ms
5,376 KB
testcase_16 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int main(void)
{
	int n, p[10001]={}, i, j, k;
	scanf("%d", &n);

	for( i = 2; i <= 100; i++) {
		for( j = 2; i*j <= 10000; j++) {
			p[i*j] = 1;
		}
	}

	int q[10001]={1,1,1,1};
	for( i = 0; i <= 10000; i++) {
		for( j = 10000; j >= 0; j--) {
			if( p[j] == 1 && i+j < 10000) {
				if( q[i] == 1 && q[i+j] != 1) {
					q[i+j] = 2;
				} else {
					q[i+j] = 1;
				}
			}
		}
	}
	
	if( q[n] == 1 ) {
		printf("Lose\n");
	} else if ( q[n] == 2 ) {
		printf("Win\n");
	}

	return 0;
}
0