結果

問題 No.7 プライムナンバーゲーム
ユーザー Dexctersu
提出日時 2017-12-21 00:50:37
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 385 ms / 5,000 ms
コード長 469 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-10-01 16:08:03
合計ジャッジ時間 3,617 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
import math
prime=[]
s=[1]*(n+1)
s[0]=s[1]=0
i=2
while i*i<=n:
    j=2
    while i*j<=n and s[i]!=0:
        s[i*j]=0
        j+=1
    i+=1
for i in range(n):
    if s[i]==1:
        prime.append(i)

winlose=[-1]*(n+1)
winlose[0],winlose[1]=1,1
for i in range(2,n+1):
    for j in prime:
        if i<j:
            break
        if winlose[i-j]==-1:
            winlose[i]=1
            break
if winlose[-1]==1:
    print("Win")
else:
    print("Lose")
0