結果

問題 No.7 プライムナンバーゲーム
ユーザー nisizawanisizawa
提出日時 2017-12-10 20:58:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 570 ms / 5,000 ms
コード長 463 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-09 04:24:23
合計ジャッジ時間 4,859 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,752 KB
testcase_01 AC 31 ms
10,880 KB
testcase_02 AC 570 ms
10,880 KB
testcase_03 AC 60 ms
10,752 KB
testcase_04 AC 38 ms
10,752 KB
testcase_05 AC 38 ms
10,752 KB
testcase_06 AC 179 ms
11,008 KB
testcase_07 AC 129 ms
10,880 KB
testcase_08 AC 75 ms
10,752 KB
testcase_09 AC 255 ms
11,008 KB
testcase_10 AC 29 ms
10,752 KB
testcase_11 AC 130 ms
10,752 KB
testcase_12 AC 394 ms
10,880 KB
testcase_13 AC 423 ms
10,880 KB
testcase_14 AC 542 ms
10,880 KB
testcase_15 AC 543 ms
10,880 KB
testcase_16 AC 514 ms
11,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def prime_ls(n):
    ls = [i for i in range(2, n + 1) if i == 2 or not i % 2 == 0]
    for i in range(3, int(n**0.5) + 1, 2):
        ls = [j for j in ls if j == i or not j % i == 0]
    return ls

n = int(input())

p_ls = prime_ls(n)
gr = [False] * (n + 1)
for i in range(4, n + 1):
    for p in p_ls:
        if i - p < 2:
            break
        if not gr[i - p]:
            gr[i] = True
            break

if gr[n]:
    print('Win')
else:
    print('Lose')
0