結果

問題 No.7 プライムナンバーゲーム
ユーザー _matumo__matumo_
提出日時 2019-11-25 09:25:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 456 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-20 21:34:14
合計ジャッジ時間 6,709 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,752 KB
testcase_01 WA -
testcase_02 AC 841 ms
10,752 KB
testcase_03 AC 77 ms
10,752 KB
testcase_04 AC 38 ms
10,624 KB
testcase_05 WA -
testcase_06 AC 260 ms
10,752 KB
testcase_07 AC 183 ms
10,624 KB
testcase_08 AC 94 ms
10,624 KB
testcase_09 WA -
testcase_10 AC 26 ms
10,752 KB
testcase_11 AC 183 ms
10,752 KB
testcase_12 AC 609 ms
10,624 KB
testcase_13 AC 644 ms
10,880 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 727 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def prime(N):
    pr=[0]*(N+1)
    R =int(N**0.5)
    for i in range(2,R+1):
        if pr[i]==0:
            for j in range(i+i,N+1,i):
                pr[j]=1
    return [n for n in range(N+1) if pr[n]==0]

def main():
    N =int(input())
    pa=prime(N)
    pb=[0]*(N+1)
    for i in range(4,N+1):
        for j in pa:
            if i-j<2:       continue
            if pb[i-j]>0:   continue
            pb[i]=1
    print(["Lose","Win"][pb[N]])

main()
0