結果

問題 No.7 プライムナンバーゲーム
ユーザー ntudantuda
提出日時 2022-10-31 00:00:37
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 696 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 86,844 KB
実行使用メモリ 84,376 KB
最終ジャッジ日時 2023-09-21 21:27:12
合計ジャッジ時間 5,208 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
72,640 KB
testcase_01 AC 121 ms
72,552 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 160 ms
79,312 KB
testcase_05 AC 157 ms
79,096 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 117 ms
72,556 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache

def seachPrimeNum(N):
    max = int(N**0.5)
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum


N = int(input())
PL = seachPrimeNum(N)

@lru_cache(maxsize=1000)
def dfs(x):
    for p in PL:
        if x < p:
            break
        if x - p == 0 or x - p == 1:
            return True
        #print(x,x-p,dfs(x-p))
        if dfs(x-p) == True:
            return False
    return True

if dfs(N):
    print("Lose")
else:
    print("Win")






0