結果

問題 No.7 プライムナンバーゲーム
ユーザー 👑 colognecologne
提出日時 2022-01-20 15:34:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 72 ms / 5,000 ms
コード長 612 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 82,516 KB
実行使用メモリ 69,316 KB
最終ジャッジ日時 2024-04-09 05:06:27
合計ジャッジ時間 2,272 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
63,376 KB
testcase_01 AC 55 ms
63,232 KB
testcase_02 AC 72 ms
67,912 KB
testcase_03 AC 67 ms
66,056 KB
testcase_04 AC 60 ms
65,516 KB
testcase_05 AC 61 ms
66,924 KB
testcase_06 AC 69 ms
67,444 KB
testcase_07 AC 65 ms
67,248 KB
testcase_08 AC 65 ms
67,456 KB
testcase_09 AC 67 ms
68,112 KB
testcase_10 AC 56 ms
63,244 KB
testcase_11 AC 67 ms
67,876 KB
testcase_12 AC 70 ms
69,108 KB
testcase_13 AC 69 ms
68,532 KB
testcase_14 AC 70 ms
68,204 KB
testcase_15 AC 71 ms
67,516 KB
testcase_16 AC 70 ms
69,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from re import L
import sys
import itertools

input = sys.stdin.readline


def main():
    N = int(input())

    sieve = [True] * (N+1)

    primes = []

    for i in range(2, N+1):
        if sieve[i]:
            primes.append(i)
            for j in range(i*i, N+1, i):
                sieve[j] = False

    DP = [False]*(N+1)
    DP[0] = DP[1] = True

    for i in range(2, N+1):
        for j in primes:
            if j > i:
                break
            if not DP[i-j]:
                DP[i] = True
                break

    print('Win' if DP[-1] else 'Lose')


if __name__ == '__main__':
    main()
0