結果

問題 No.7 プライムナンバーゲーム
コンテスト
ユーザー yn
提出日時 2015-09-25 16:49:15
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 206 ms / 5,000 ms
コード長 492 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 542 ms
コンパイル使用メモリ 20,696 KB
実行使用メモリ 15,356 KB
最終ジャッジ日時 2026-04-17 17:20:19
合計ジャッジ時間 4,982 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n = int(input())

M = 10000
table = [True] * (M + 1)
num = []

for i in range(2, M + 1):
    if not table[i]:
        continue
    k = i + i
    while k < M + 1:
        table[k] = False
        k += i

    num.append(i)

memo = [False] * 10001

for i in range(2,10001):
    if memo[i]:
        continue
    for p in num:
        if i + p > 10000:
            break
        memo[i+p] = True

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