結果

問題 No.7 プライムナンバーゲーム
ユーザー DexctersuDexctersu
提出日時 2017-12-21 00:50:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 463 ms / 5,000 ms
コード長 469 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-09 04:24:31
合計ジャッジ時間 4,334 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,880 KB
testcase_01 AC 31 ms
10,880 KB
testcase_02 AC 463 ms
11,008 KB
testcase_03 AC 62 ms
10,880 KB
testcase_04 AC 40 ms
10,880 KB
testcase_05 AC 37 ms
10,880 KB
testcase_06 AC 151 ms
11,136 KB
testcase_07 AC 112 ms
11,008 KB
testcase_08 AC 67 ms
10,880 KB
testcase_09 AC 216 ms
11,008 KB
testcase_10 AC 30 ms
10,880 KB
testcase_11 AC 114 ms
11,008 KB
testcase_12 AC 333 ms
11,008 KB
testcase_13 AC 338 ms
11,008 KB
testcase_14 AC 463 ms
10,880 KB
testcase_15 AC 418 ms
11,008 KB
testcase_16 AC 402 ms
11,008 KB
権限があれば一括ダウンロードができます

ソースコード

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