結果

問題 No.7 プライムナンバーゲーム
ユーザー ABKZABKZ
提出日時 2021-11-03 21:34:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 125 ms / 5,000 ms
コード長 511 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 82,160 KB
実行使用メモリ 76,524 KB
最終ジャッジ日時 2024-04-09 05:05:26
合計ジャッジ時間 2,392 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,868 KB
testcase_01 AC 37 ms
52,444 KB
testcase_02 AC 123 ms
76,464 KB
testcase_03 AC 57 ms
67,156 KB
testcase_04 AC 49 ms
63,716 KB
testcase_05 AC 48 ms
62,456 KB
testcase_06 AC 78 ms
76,208 KB
testcase_07 AC 66 ms
74,136 KB
testcase_08 AC 60 ms
69,116 KB
testcase_09 AC 87 ms
76,036 KB
testcase_10 AC 39 ms
52,300 KB
testcase_11 AC 66 ms
74,472 KB
testcase_12 AC 104 ms
76,112 KB
testcase_13 AC 109 ms
76,524 KB
testcase_14 AC 125 ms
76,484 KB
testcase_15 AC 123 ms
76,376 KB
testcase_16 AC 117 ms
76,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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