結果

問題 No.7 プライムナンバーゲーム
ユーザー pekempeypekempey
提出日時 2015-08-23 17:28:18
言語 Python2
(2.7.18)
結果
RE  
実行時間 -
コード長 407 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 6,692 KB
実行使用メモリ 6,924 KB
最終ジャッジ日時 2023-09-25 16:19:16
合計ジャッジ時間 1,702 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
6,152 KB
testcase_01 AC 15 ms
6,044 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 64 ms
6,296 KB
testcase_05 AC 63 ms
6,348 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 14 ms
6,200 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(raw_input())

prime = []
good = [True] * 10101

for i in xrange(2, 10101):
	if good[i]:
		prime.append(i)
		for j in xrange(i * i, 10101, i):
			good[j] = False

memo = [None] * 10101

def judge(n):
	global memo
	if n <= 1: return True
	if not memo[n] is None: return memo[n]
	memo[n] = any([not judge(n - p) for p in prime if p <= n])
	return memo[n]

if judge(N):
	print "Win"
else:
	print "Lose"
0