結果

問題 No.7 プライムナンバーゲーム
ユーザー koyoprokoyopro
提出日時 2015-09-20 10:50:21
言語 Python2
(2.7.18)
結果
AC  
実行時間 741 ms / 5,000 ms
コード長 499 bytes
コンパイル時間 366 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 03:51:50
合計ジャッジ時間 14,139 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 740 ms
6,820 KB
testcase_01 AC 737 ms
6,944 KB
testcase_02 AC 734 ms
6,944 KB
testcase_03 AC 734 ms
6,944 KB
testcase_04 AC 733 ms
6,944 KB
testcase_05 AC 735 ms
6,948 KB
testcase_06 AC 737 ms
6,948 KB
testcase_07 AC 737 ms
6,944 KB
testcase_08 AC 735 ms
6,944 KB
testcase_09 AC 734 ms
6,948 KB
testcase_10 AC 735 ms
6,944 KB
testcase_11 AC 740 ms
6,944 KB
testcase_12 AC 735 ms
6,944 KB
testcase_13 AC 735 ms
6,944 KB
testcase_14 AC 737 ms
6,944 KB
testcase_15 AC 737 ms
6,944 KB
testcase_16 AC 741 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-

primes = [2]

for i in xrange(3, 10000, 2):
    for p in primes:
        if i % p == 0:
            break
    else:
        primes.append(i)

n, = map(int, raw_input().split())

win = [None for x in xrange(10001)]

for i in xrange(2, 10001):
    for p in primes:
        if i - p <= 1:
            win[i] = False
            break
        if win[i-p] == None: continue
        if not win[i - p]:
            win[i] = True
            break
print 'Win' if win[n] else 'Lose'
0