結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,560 KB
testcase_01 AC 10 ms
6,688 KB
testcase_02 AC 1,591 ms
7,040 KB
testcase_03 AC 110 ms
6,688 KB
testcase_04 AC 37 ms
6,692 KB
testcase_05 AC 36 ms
6,692 KB
testcase_06 AC 465 ms
6,912 KB
testcase_07 AC 316 ms
6,784 KB
testcase_08 AC 147 ms
6,692 KB
testcase_09 AC 704 ms
6,784 KB
testcase_10 AC 11 ms
6,692 KB
testcase_11 AC 322 ms
6,784 KB
testcase_12 AC 1,131 ms
6,912 KB
testcase_13 AC 1,199 ms
7,040 KB
testcase_14 AC 1,578 ms
7,040 KB
testcase_15 AC 1,495 ms
7,040 KB
testcase_16 AC 1,373 ms
7,040 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
			break

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