結果

問題 No.7 プライムナンバーゲーム
ユーザー dashi_dragonsdashi_dragons
提出日時 2017-02-14 22:42:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 543 bytes
コンパイル時間 119 ms
コンパイル使用メモリ 11,000 KB
実行使用メモリ 9,092 KB
最終ジャッジ日時 2023-08-28 17:01:23
合計ジャッジ時間 5,626 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,028 KB
testcase_01 AC 16 ms
7,940 KB
testcase_02 AC 651 ms
8,916 KB
testcase_03 AC 52 ms
8,580 KB
testcase_04 AC 24 ms
8,500 KB
testcase_05 WA -
testcase_06 AC 192 ms
8,632 KB
testcase_07 AC 134 ms
8,572 KB
testcase_08 AC 66 ms
8,560 KB
testcase_09 WA -
testcase_10 AC 15 ms
8,064 KB
testcase_11 AC 135 ms
8,608 KB
testcase_12 AC 459 ms
9,088 KB
testcase_13 AC 488 ms
8,908 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 560 ms
9,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
import sys

def cal_prm(N):
	
	prm = []
	
	for i in range(2,N):
		flag = True

		for j in range(2,i):
			if i % j == 0:
				flag = False
				break
		if flag == True:
			prm.append(i)
	return prm

def judge(N):

	list = {2:False,3:False}
	prm = cal_prm(N)

	for i in range(4,N+1):

		flag = True
		for j in prm:
			if i - j < 2:
				break
	
			if list[i-j] == False:
				list[i] = True
				break

		if i not in list:	
			list[i] = False

	return list

N = int(input())

if judge(N)[N-1] == True:
	print('Win')
else:
	print('Lose')	
0