結果

問題 No.7 プライムナンバーゲーム
ユーザー lloyzlloyz
提出日時 2022-01-11 21:36:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 552 ms / 5,000 ms
コード長 553 bytes
コンパイル時間 340 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-09 05:06:44
合計ジャッジ時間 5,040 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
10,880 KB
testcase_01 AC 33 ms
11,008 KB
testcase_02 AC 552 ms
11,008 KB
testcase_03 AC 66 ms
10,880 KB
testcase_04 AC 40 ms
11,008 KB
testcase_05 AC 41 ms
11,008 KB
testcase_06 AC 176 ms
10,880 KB
testcase_07 AC 133 ms
10,880 KB
testcase_08 AC 76 ms
10,880 KB
testcase_09 AC 259 ms
10,880 KB
testcase_10 AC 33 ms
10,880 KB
testcase_11 AC 135 ms
10,880 KB
testcase_12 AC 395 ms
10,880 KB
testcase_13 AC 426 ms
11,008 KB
testcase_14 AC 541 ms
10,880 KB
testcase_15 AC 533 ms
10,880 KB
testcase_16 AC 473 ms
11,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

P = []
Prime = [True for _ in range(10001)]
Prime[0] = Prime[1] = False
for i in range(2, 10001):
    if Prime[i]:
        P.append(i)
        for j in range(2 * i, 10001, i):
            Prime[j] = False

n = int(input())
Win = [False for _ in range(n + 1)]
for i in range(4, n + 1):
    for prime in P:
        if i - prime < 2:
            Win[i] = False
            break
        else:
            if not Win[i - prime]:
                Win[i] = True
                break
if Win[n]:
    print("Win")
else:
    print("Lose")
0