結果

問題 No.7 プライムナンバーゲーム
ユーザー mkawa2mkawa2
提出日時 2019-04-18 21:56:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 599 ms / 5,000 ms
コード長 398 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-09 04:37:43
合計ジャッジ時間 5,228 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 29 ms
10,752 KB
testcase_02 AC 597 ms
10,752 KB
testcase_03 AC 64 ms
10,752 KB
testcase_04 AC 37 ms
10,752 KB
testcase_05 AC 37 ms
10,752 KB
testcase_06 AC 197 ms
10,752 KB
testcase_07 AC 144 ms
10,752 KB
testcase_08 AC 77 ms
10,752 KB
testcase_09 AC 277 ms
10,880 KB
testcase_10 AC 28 ms
10,752 KB
testcase_11 AC 147 ms
10,880 KB
testcase_12 AC 481 ms
10,752 KB
testcase_13 AC 455 ms
10,752 KB
testcase_14 AC 599 ms
10,880 KB
testcase_15 AC 566 ms
10,752 KB
testcase_16 AC 526 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
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]

for i in range(4,n+1):
    for s in sosu:
        if s>i-2:
            dp[i]=-1
            break
        if dp[i-s]==-1:
            dp[i]=1
            break
    else:
        dp[i]=-1
print("Win") if dp[-1]==1 else print("Lose")
0