結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 29 ms
10,752 KB
testcase_02 AC 1,861 ms
11,008 KB
testcase_03 AC 143 ms
10,752 KB
testcase_04 AC 61 ms
10,752 KB
testcase_05 AC 58 ms
10,880 KB
testcase_06 AC 544 ms
10,880 KB
testcase_07 AC 405 ms
10,752 KB
testcase_08 AC 182 ms
10,752 KB
testcase_09 AC 836 ms
10,880 KB
testcase_10 AC 29 ms
10,752 KB
testcase_11 AC 387 ms
10,880 KB
testcase_12 AC 1,313 ms
11,008 KB
testcase_13 AC 1,406 ms
11,008 KB
testcase_14 AC 1,859 ms
11,136 KB
testcase_15 AC 1,845 ms
11,136 KB
testcase_16 AC 1,625 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 = [0] * (n + 1)
for i in range(4, n + 1):
    s = []
    for p in p_ls:
        if i - p < 2:
            break
        s.append(gr[i - p])
    for j in range(i):
        if not j in s:
            gr[i] = j
            break
if gr[n] == 0:
    print('Lose')
else:
    print('Win')
0