結果

問題 No.7 プライムナンバーゲーム
ユーザー mlihua09mlihua09
提出日時 2020-08-23 12:04:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 57 ms / 5,000 ms
コード長 604 bytes
コンパイル時間 631 ms
コンパイル使用メモリ 82,596 KB
実行使用メモリ 61,780 KB
最終ジャッジ日時 2024-04-09 04:58:29
合計ジャッジ時間 2,108 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,272 KB
testcase_01 AC 36 ms
54,012 KB
testcase_02 AC 44 ms
60,752 KB
testcase_03 AC 45 ms
60,204 KB
testcase_04 AC 40 ms
59,596 KB
testcase_05 AC 41 ms
59,316 KB
testcase_06 AC 42 ms
60,056 KB
testcase_07 AC 42 ms
60,068 KB
testcase_08 AC 42 ms
61,028 KB
testcase_09 AC 48 ms
60,600 KB
testcase_10 AC 41 ms
53,352 KB
testcase_11 AC 43 ms
60,868 KB
testcase_12 AC 53 ms
61,712 KB
testcase_13 AC 42 ms
59,764 KB
testcase_14 AC 57 ms
61,572 KB
testcase_15 AC 56 ms
61,624 KB
testcase_16 AC 54 ms
61,780 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