結果

問題 No.7 プライムナンバーゲーム
ユーザー tjaketjake
提出日時 2015-12-06 03:33:39
言語 Python2
(2.7.18)
結果
AC  
実行時間 177 ms / 5,000 ms
コード長 378 bytes
コンパイル時間 57 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 03:52:13
合計ジャッジ時間 2,098 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,816 KB
testcase_01 AC 12 ms
6,948 KB
testcase_02 AC 177 ms
6,948 KB
testcase_03 AC 22 ms
6,948 KB
testcase_04 AC 15 ms
6,944 KB
testcase_05 AC 15 ms
6,944 KB
testcase_06 AC 58 ms
6,948 KB
testcase_07 AC 44 ms
6,948 KB
testcase_08 AC 26 ms
6,944 KB
testcase_09 AC 83 ms
6,948 KB
testcase_10 AC 12 ms
6,944 KB
testcase_11 AC 43 ms
6,948 KB
testcase_12 AC 126 ms
6,944 KB
testcase_13 AC 134 ms
6,948 KB
testcase_14 AC 171 ms
6,944 KB
testcase_15 AC 163 ms
6,948 KB
testcase_16 AC 154 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt
n = input()

prime = [0]*2 + [1]*n
for i in xrange(2, int(sqrt(n))+1):
    if prime[i]:
        for j in xrange(i*i, n+1, i):
            prime[j] = 0
ps = [x for x in xrange(n+1) if prime[x]]

can = [0]*2 + [1]*n

for i in xrange(2, n):
    if can[i]:
        for j in ps:
            if i+j > n: break
            can[i+j] = 0
print "Lose"*can[n]or"Win"
0