結果

問題 No.7 プライムナンバーゲーム
ユーザー flippergoflippergo
提出日時 2020-12-21 20:14:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 606 ms / 5,000 ms
コード長 543 bytes
コンパイル時間 526 ms
コンパイル使用メモリ 82,312 KB
実行使用メモリ 83,848 KB
最終ジャッジ日時 2024-04-09 05:01:25
合計ジャッジ時間 5,676 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
61,172 KB
testcase_01 AC 44 ms
59,964 KB
testcase_02 AC 606 ms
83,848 KB
testcase_03 AC 59 ms
66,648 KB
testcase_04 AC 53 ms
63,968 KB
testcase_05 AC 54 ms
64,180 KB
testcase_06 AC 174 ms
79,596 KB
testcase_07 AC 127 ms
78,656 KB
testcase_08 AC 64 ms
69,156 KB
testcase_09 AC 260 ms
80,372 KB
testcase_10 AC 46 ms
60,872 KB
testcase_11 AC 133 ms
80,684 KB
testcase_12 AC 418 ms
81,952 KB
testcase_13 AC 445 ms
82,344 KB
testcase_14 AC 599 ms
83,244 KB
testcase_15 AC 570 ms
82,960 KB
testcase_16 AC 521 ms
82,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10000)
P = [1 for _ in range(10**4)]
P[0]=0
P[1]=0
for i in range(2,101):
    for j in range(i*i,10**4,i):
        P[j]=0
Q = []
for i in range(2,10**4):
    if P[i]==1:
        Q.append(i)
memo = {}
def f(n):
    if n==2:
        return "Lose"
    if n==3:
        return "Lose"
    if n in memo:
        return memo[n]
    for q in Q:
        if q>=n:break
        if q<=n-2 and f(n-q)=="Lose":
            memo[n]="Win"
            return memo[n]
    memo[n]="Lose"
    return memo[n]
print(f(int(input())))
0