結果

問題 No.7 プライムナンバーゲーム
ユーザー HydruHydru
提出日時 2023-01-15 20:53:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 95 ms / 5,000 ms
コード長 640 bytes
コンパイル時間 1,115 ms
コンパイル使用メモリ 86,424 KB
実行使用メモリ 76,892 KB
最終ジャッジ日時 2023-08-28 13:05:54
合計ジャッジ時間 3,270 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,180 KB
testcase_01 AC 73 ms
71,292 KB
testcase_02 AC 95 ms
76,848 KB
testcase_03 AC 84 ms
76,356 KB
testcase_04 AC 80 ms
76,304 KB
testcase_05 AC 80 ms
76,224 KB
testcase_06 AC 85 ms
76,392 KB
testcase_07 AC 84 ms
76,404 KB
testcase_08 AC 80 ms
76,164 KB
testcase_09 AC 84 ms
76,408 KB
testcase_10 AC 72 ms
71,080 KB
testcase_11 AC 86 ms
76,668 KB
testcase_12 AC 88 ms
76,564 KB
testcase_13 AC 89 ms
76,684 KB
testcase_14 AC 93 ms
76,892 KB
testcase_15 AC 92 ms
76,696 KB
testcase_16 AC 91 ms
76,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())

# nまでの素数を要素にもつ集合を返す関数
def eratosthenes(n):
    primes=set(range(2,n+1))
    for i in range(2,n):
        if i in primes:
            it = i ** 2
            while it <= n:
                if it in primes:
                    primes.remove(it)
                it += i
    return primes

P=sorted(list(eratosthenes(n)))

flag=[-1 for _ in range(n+1)]

flag[0]=1
flag[1]=1

for i in range(2,n+1):
    key=0
    for p in P:
        if p>i:
            break
        if flag[i-p]==0:
            key=1
            break
    flag[i]=key

if flag[n]==1:
    print("Win")
else:
    print("Lose")
0