結果

問題 No.7 プライムナンバーゲーム
ユーザー hiro_hiro_hirophiro_hiro_hirop
提出日時 2018-06-05 09:48:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 753 ms / 5,000 ms
コード長 328 bytes
コンパイル時間 144 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-09 04:29:16
合計ジャッジ時間 6,007 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,752 KB
testcase_01 AC 32 ms
10,752 KB
testcase_02 AC 753 ms
11,136 KB
testcase_03 AC 67 ms
10,752 KB
testcase_04 AC 37 ms
10,880 KB
testcase_05 AC 36 ms
10,752 KB
testcase_06 AC 217 ms
10,752 KB
testcase_07 AC 147 ms
10,752 KB
testcase_08 AC 79 ms
10,880 KB
testcase_09 AC 328 ms
10,752 KB
testcase_10 AC 29 ms
10,752 KB
testcase_11 AC 151 ms
10,752 KB
testcase_12 AC 528 ms
11,008 KB
testcase_13 AC 567 ms
10,880 KB
testcase_14 AC 747 ms
10,880 KB
testcase_15 AC 700 ms
11,008 KB
testcase_16 AC 642 ms
11,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

prime_bool = [0]*2+[1]*(n-1)
for i in range(2,n+1):
    if prime_bool[i] == 1:
        for j in range(i*2, n+1, i):
            prime_bool[j] = 0

lose_set = {2,3}
for i in range(4,n+1):
    if not(any([prime_bool[i-x]==1 for x in lose_set])):
        lose_set |= {i}

print('Lose' if n in lose_set else 'Win')
0