結果

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

ソースコード

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