結果

問題 No.7 プライムナンバーゲーム
ユーザー shinshin
提出日時 2022-10-16 16:35:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 281 ms / 5,000 ms
コード長 535 bytes
コンパイル時間 764 ms
コンパイル使用メモリ 10,856 KB
実行使用メモリ 8,348 KB
最終ジャッジ日時 2023-09-09 19:06:44
合計ジャッジ時間 2,982 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,812 KB
testcase_01 AC 15 ms
7,760 KB
testcase_02 AC 281 ms
8,260 KB
testcase_03 AC 31 ms
7,920 KB
testcase_04 AC 19 ms
7,844 KB
testcase_05 AC 19 ms
7,856 KB
testcase_06 AC 88 ms
8,348 KB
testcase_07 AC 65 ms
8,292 KB
testcase_08 AC 38 ms
7,840 KB
testcase_09 AC 130 ms
8,292 KB
testcase_10 AC 15 ms
7,888 KB
testcase_11 AC 66 ms
8,324 KB
testcase_12 AC 201 ms
8,348 KB
testcase_13 AC 213 ms
8,272 KB
testcase_14 AC 277 ms
8,284 KB
testcase_15 AC 277 ms
8,240 KB
testcase_16 AC 250 ms
8,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#プライムナンバーゲーム

N = int(input())

p = [True for i in range(N+1)]
p_list = []

b = [False for i in range(N + 1)]

for i in range(2 , N+1):
    if p[i]:
        p_list.append(i)
        for j in range(N // i + 1):
            p[i * j] = False
    else:
        continue

for i in range(2 , N + 1):
    if b[i]:
        continue
    else:
        for k in p_list:
            if i + k <= N:
                b[i + k] = True
            else:
                continue

if b[-1]:
    print("Win")
else:
    print("Lose")
0