結果

問題 No.7 プライムナンバーゲーム
ユーザー mkawa2mkawa2
提出日時 2019-04-19 00:48:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 450 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 11,896 KB
実行使用メモリ 10,584 KB
最終ジャッジ日時 2023-10-23 16:42:38
合計ジャッジ時間 2,214 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,100 KB
testcase_01 AC 27 ms
10,100 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 39 ms
10,164 KB
testcase_05 AC 37 ms
10,164 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 28 ms
10,100 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(n):
    if n<4:
        return "Lose"
    if memo[n]!=0:
        return memo[n]
    for s in sosu:
        if s>n-2:
            break
        if f(n-s)=="Lose":
            memo[n]="Win"
            return "Win"
    memo[n] = "Lose"
    return "Lose"

n=int(input())
memo=[0]*(n+1)
sosu=[2]
dp=[0]*(n+1)
dp[2]=-1
dp[3]=-1
for i in range(3,n+1,2):
    for s in sosu:
        if i%s==0:
            break
    else:
        sosu+=[i]
print(f(n))
0