結果

問題 No.7 プライムナンバーゲーム
ユーザー 🍡yurahuna🍡yurahuna
提出日時 2016-04-28 20:58:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 131 ms / 5,000 ms
コード長 489 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 82,516 KB
実行使用メモリ 64,204 KB
最終ジャッジ日時 2024-04-09 03:58:08
合計ジャッジ時間 2,465 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,008 KB
testcase_01 AC 36 ms
53,292 KB
testcase_02 AC 131 ms
63,260 KB
testcase_03 AC 53 ms
62,948 KB
testcase_04 AC 52 ms
61,928 KB
testcase_05 AC 48 ms
62,088 KB
testcase_06 AC 73 ms
63,592 KB
testcase_07 AC 64 ms
63,676 KB
testcase_08 AC 54 ms
63,584 KB
testcase_09 AC 85 ms
64,204 KB
testcase_10 AC 37 ms
52,628 KB
testcase_11 AC 65 ms
63,128 KB
testcase_12 AC 107 ms
64,048 KB
testcase_13 AC 112 ms
63,260 KB
testcase_14 AC 131 ms
63,348 KB
testcase_15 AC 127 ms
64,172 KB
testcase_16 AC 121 ms
64,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

prime = []
def setPrime(n):
    n += 1
    alive = [True] * n
    i = 2
    while i < n:
        if alive[i]:
            prime.append(i)
            j = 2 * i
            while j < n:
                alive[j] = False
                j += i
        i += 1

N = int(input())
setPrime(N)
dp = [False] * (N + 1)
dp[0] = dp[1] = True
for i in range(2, N + 1):
    for p in prime:
        if i - p < 0:
            break
        dp[i] |= not dp[i - p]

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