結果

問題 No.7 プライムナンバーゲーム
ユーザー Snark86Snark86
提出日時 2016-04-25 03:32:08
言語 Python2
(2.7.18)
結果
AC  
実行時間 2,239 ms / 5,000 ms
コード長 400 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 7,040 KB
最終ジャッジ日時 2024-04-09 03:58:40
合計ジャッジ時間 15,866 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,816 KB
testcase_01 AC 12 ms
6,948 KB
testcase_02 AC 2,239 ms
6,948 KB
testcase_03 AC 152 ms
6,948 KB
testcase_04 AC 48 ms
6,944 KB
testcase_05 AC 47 ms
6,944 KB
testcase_06 AC 663 ms
6,944 KB
testcase_07 AC 442 ms
6,944 KB
testcase_08 AC 202 ms
6,944 KB
testcase_09 AC 992 ms
6,944 KB
testcase_10 AC 11 ms
6,948 KB
testcase_11 AC 449 ms
6,944 KB
testcase_12 AC 1,604 ms
7,040 KB
testcase_13 AC 1,695 ms
6,944 KB
testcase_14 AC 2,224 ms
6,948 KB
testcase_15 AC 2,115 ms
6,944 KB
testcase_16 AC 1,940 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
N = int(raw_input())
primes = []
nums = range(2,N+1)
while nums:
	num = nums.pop(0)
	primes.append(num)
	if num > math.sqrt(N):
		primes += nums
		break
	else:
		nums = filter(lambda x:x%num!=0, nums)

game = [True, True]+[False for _ in range(N-1)]
for i in range(2,N+1):
	for j in filter(lambda x:x<i+1,primes):
		if game[i-j] == False: game[i]=True

print "Win" if game[-1] else "Lose"
0