結果

問題 No.7 プライムナンバーゲーム
コンテスト
ユーザー ABKZ
提出日時 2021-11-03 21:34:48
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 88 ms / 5,000 ms
コード長 511 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 320 ms
コンパイル使用メモリ 84,864 KB
実行使用メモリ 81,280 KB
最終ジャッジ日時 2026-04-17 18:36:02
合計ジャッジ時間 2,164 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N = int(input())

nums = list(range(2, N+1))

primes = []
work = nums[:]
while len(work) > 0:
    head = work.pop(0)
    primes.append(head)
    work = list(filter(lambda x: x % head != 0, work))

win_nums = set()
while len(nums) > 0:
    head = nums.pop(0)
    for n in primes:
        win_num = n + head
        if win_num > N:
            break
        if not win_num in win_nums:
            win_nums.add(win_num)
            nums.remove(win_num)

if N in win_nums:
    print("Win")
else:
    print("Lose")
0