結果

問題 No.7 プライムナンバーゲーム
ユーザー mlihua09mlihua09
提出日時 2020-08-23 12:04:24
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 86 ms / 5,000 ms
コード長 604 bytes
コンパイル時間 500 ms
コンパイル使用メモリ 87,160 KB
実行使用メモリ 76,348 KB
最終ジャッジ日時 2023-07-24 21:39:55
合計ジャッジ時間 2,798 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,316 KB
testcase_01 AC 71 ms
71,196 KB
testcase_02 AC 73 ms
76,016 KB
testcase_03 AC 71 ms
75,952 KB
testcase_04 AC 74 ms
75,760 KB
testcase_05 AC 78 ms
75,956 KB
testcase_06 AC 77 ms
75,884 KB
testcase_07 AC 72 ms
76,196 KB
testcase_08 AC 76 ms
76,036 KB
testcase_09 AC 78 ms
76,016 KB
testcase_10 AC 67 ms
71,332 KB
testcase_11 AC 70 ms
76,064 KB
testcase_12 AC 82 ms
76,344 KB
testcase_13 AC 71 ms
75,920 KB
testcase_14 AC 86 ms
76,220 KB
testcase_15 AC 85 ms
76,348 KB
testcase_16 AC 85 ms
76,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


import math


N = int(input())

isprime = [0, 0] + [1] * (N - 1)

for i in range(2, int(math.sqrt(N)) + 1):
    
    if isprime[i]:
        
        for j in range(2 * i, N + 1, i):
            
            isprime[j] = 0

Prime = [i for i in range(N + 1) if isprime[i]]

W = [-1] * (N + 1)

W[0] = 1
W[1] = 1

while W[-1] == -1:
    
    x = W.index(-1)
    
    W[x] = 0
    
    for p in Prime:
        
        if x + p <= N:
            
            W[x + p] = 1
            
        else:
            
            break

if W[-1]:
    
    print('Win')
    
else:
    
    print('Lose')
    
    
0