結果

問題 No.7 プライムナンバーゲーム
コンテスト
ユーザー r_ishida
提出日時 2026-01-02 19:18:53
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 383 ms / 5,000 ms
+ 545µs
コード長 686 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 57 ms
コンパイル使用メモリ 15,232 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2026-10-11 11:51:32
合計ジャッジ時間 5,234 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import math
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

n = I()

p = [2]
for i in range(2, 10000):
    for j in p:
        if i % j == 0:
            break
    else:
        p.append(i)

dp = [0] * (n+1)

for i in range(4, n+1):
    ret = 0
    for j in p:
        if j > i-2:
            break
        if not dp[i-j]:
            ret = 1
            break
    dp[i] = ret

if dp[n]:
    print("Win")
else:
    print("Lose")
0