結果

問題 No.7 プライムナンバーゲーム
ユーザー dashi_dragonsdashi_dragons
提出日時 2017-02-14 22:44:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 848 ms / 5,000 ms
コード長 541 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,648 KB
最終ジャッジ日時 2024-04-09 04:11:11
合計ジャッジ時間 6,808 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,880 KB
testcase_01 AC 30 ms
10,880 KB
testcase_02 AC 848 ms
11,648 KB
testcase_03 AC 78 ms
11,136 KB
testcase_04 AC 41 ms
11,008 KB
testcase_05 AC 40 ms
11,008 KB
testcase_06 AC 258 ms
11,264 KB
testcase_07 AC 181 ms
11,136 KB
testcase_08 AC 94 ms
11,136 KB
testcase_09 AC 385 ms
11,520 KB
testcase_10 AC 30 ms
10,880 KB
testcase_11 AC 182 ms
11,392 KB
testcase_12 AC 610 ms
11,648 KB
testcase_13 AC 642 ms
11,648 KB
testcase_14 AC 846 ms
11,648 KB
testcase_15 AC 804 ms
11,520 KB
testcase_16 AC 746 ms
11,520 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] == True:
	print('Win')
else:
	print('Lose')	
0