結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,752 KB
testcase_01 AC 28 ms
10,880 KB
testcase_02 AC 875 ms
11,008 KB
testcase_03 AC 71 ms
10,752 KB
testcase_04 AC 38 ms
10,752 KB
testcase_05 AC 38 ms
10,752 KB
testcase_06 AC 253 ms
10,880 KB
testcase_07 AC 169 ms
10,880 KB
testcase_08 AC 88 ms
10,752 KB
testcase_09 AC 382 ms
10,880 KB
testcase_10 AC 28 ms
10,752 KB
testcase_11 AC 168 ms
10,880 KB
testcase_12 AC 611 ms
11,008 KB
testcase_13 AC 653 ms
11,008 KB
testcase_14 AC 866 ms
11,008 KB
testcase_15 AC 836 ms
11,008 KB
testcase_16 AC 762 ms
11,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

prime_judge_lst = [1]*(n+1)
prime_set = {2}
for i in range(2,n+1):
    if prime_judge_lst[i] == 1:
        prime_set = prime_set|{i}
        for j in range(i*2, n+1, i):
            prime_judge_lst[j] = 0

lose_set = {2,3}
for i in range(4,n+1):
    if not(any([i-x in prime_set for x in lose_set])):
        lose_set = lose_set|{i}
        
print('Lose' if n in lose_set else 'Win')
0