結果

問題 No.7 プライムナンバーゲーム
ユーザー asaka189asaka189
提出日時 2018-01-02 13:39:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 462 bytes
コンパイル時間 384 ms
コンパイル使用メモリ 10,788 KB
実行使用メモリ 8,628 KB
最終ジャッジ日時 2023-08-24 16:54:15
合計ジャッジ時間 19,584 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,960 KB
testcase_01 AC 15 ms
7,896 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 58 ms
7,768 KB
testcase_06 WA -
testcase_07 AC 532 ms
7,820 KB
testcase_08 AC 251 ms
7,936 KB
testcase_09 AC 1,180 ms
7,776 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2,711 ms
8,380 KB
testcase_15 AC 2,629 ms
8,448 KB
testcase_16 AC 2,351 ms
8,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
table = [0 for i in range(n)]
table[1] = 'Lose' #2のとき
table[2] = 'Lose' #3のとき

p = []
for i in range(3,n):
	check = True
	for k in range(2,int(i**0.5)+2):
		if i%k == 0:
			check = False
	if check:
		p.append(i)
p.insert(0,2)

l = len(p)
for i in range(4,n+1):
	k = 0
	while i-p[k] > 1 and k != l-1:
		if table[i-p[k]-1] == 0:
			table[i-1] = 'Lose'
			k += 1
		else:
			k += 1

if table[n-1] == 0:
	print('Win')
else:
	print('Lose')
0