結果

問題 No.7 プライムナンバーゲーム
ユーザー netyo715netyo715
提出日時 2021-06-21 11:36:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 603 ms / 5,000 ms
コード長 402 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-04-09 05:04:20
合計ジャッジ時間 5,472 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
11,520 KB
testcase_01 AC 30 ms
11,520 KB
testcase_02 AC 603 ms
12,288 KB
testcase_03 AC 69 ms
11,648 KB
testcase_04 AC 39 ms
11,520 KB
testcase_05 AC 39 ms
11,520 KB
testcase_06 AC 211 ms
12,160 KB
testcase_07 AC 141 ms
11,776 KB
testcase_08 AC 81 ms
11,776 KB
testcase_09 AC 291 ms
12,160 KB
testcase_10 AC 30 ms
11,520 KB
testcase_11 AC 139 ms
11,776 KB
testcase_12 AC 453 ms
12,288 KB
testcase_13 AC 470 ms
12,160 KB
testcase_14 AC 597 ms
12,160 KB
testcase_15 AC 601 ms
12,288 KB
testcase_16 AC 531 ms
12,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

hurui = set(range(2, N+1))
for i in range(2, N+1):
    for j in range(i*2, N+1, i):
        hurui.discard(j)

f = [False]*100000
f[0] = True
f[1] = True
for i in range(2, N+1):
    flag = False
    for j in hurui:
        if j > i:
            continue
        if not f[i-j]:
            flag = True
            break
    f[i] = flag

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