結果

問題 No.7 プライムナンバーゲーム
ユーザー _matumo__matumo_
提出日時 2019-11-25 14:58:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 678 ms / 5,000 ms
コード長 449 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-09 04:46:39
合計ジャッジ時間 5,612 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,880 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 678 ms
10,880 KB
testcase_03 AC 66 ms
10,880 KB
testcase_04 AC 37 ms
10,752 KB
testcase_05 AC 37 ms
10,752 KB
testcase_06 AC 212 ms
10,880 KB
testcase_07 AC 150 ms
10,880 KB
testcase_08 AC 81 ms
10,752 KB
testcase_09 AC 307 ms
10,880 KB
testcase_10 AC 28 ms
10,752 KB
testcase_11 AC 151 ms
10,752 KB
testcase_12 AC 486 ms
10,752 KB
testcase_13 AC 515 ms
10,880 KB
testcase_14 AC 673 ms
11,008 KB
testcase_15 AC 628 ms
11,008 KB
testcase_16 AC 588 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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:       break
            if pb[i-j]>0:   continue
            pb[i]=1
    print(["Lose","Win"][pb[N]])

main()
0