結果

問題 No.7 プライムナンバーゲーム
コンテスト
ユーザー OblongVeil4309
提出日時 2025-04-22 01:51:41
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 139 ms / 5,000 ms
+ 777µs
コード長 783 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 81 ms
コンパイル使用メモリ 64,828 KB
実行使用メモリ 60,032 KB
最終ジャッジ日時 2026-11-16 22:18:06
合計ジャッジ時間 2,939 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N=int(input())
if N == 2 or N == 3:
    print("Lose")
    exit()

lose_num=set()
lose_num.add(2)
lose_num.add(3)

def Sieve_of_Eratosthenes(num):
    number_list = [[i,True] for i in range(0,num+1)]
    prime_list = []
    for i, res in number_list[2:]:
        if res == True:
            for j in range(i*i, num+1, i):
                number_list[j][1] = False

        if i > num**(1/2):
            break
    for num,i in number_list:
        if num >= 2 and i == True:
            prime_list.append(num)
    return prime_list

prime_set=set(Sieve_of_Eratosthenes(N+10))

for i in range(4,N+1):
    found=False
    for j in lose_num:
        if i-j in prime_set:
            found=True
    
    if not found:
        lose_num.add(i)

print("Win" if i not in lose_num else "Lose")
0