結果

問題 No.7 プライムナンバーゲーム
ユーザー ynyn
提出日時 2015-09-25 16:49:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 246 ms / 5,000 ms
コード長 492 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-09 03:50:37
合計ジャッジ時間 5,084 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 224 ms
10,880 KB
testcase_01 AC 226 ms
10,880 KB
testcase_02 AC 239 ms
11,008 KB
testcase_03 AC 239 ms
10,880 KB
testcase_04 AC 225 ms
11,008 KB
testcase_05 AC 225 ms
10,880 KB
testcase_06 AC 237 ms
10,880 KB
testcase_07 AC 222 ms
10,880 KB
testcase_08 AC 231 ms
11,008 KB
testcase_09 AC 236 ms
10,880 KB
testcase_10 AC 231 ms
11,008 KB
testcase_11 AC 222 ms
10,880 KB
testcase_12 AC 222 ms
10,880 KB
testcase_13 AC 222 ms
10,880 KB
testcase_14 AC 227 ms
10,880 KB
testcase_15 AC 246 ms
10,880 KB
testcase_16 AC 224 ms
11,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/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