結果

問題 No.7 プライムナンバーゲーム
ユーザー mationaruzoumationaruzou
提出日時 2020-06-19 14:39:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 496 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 10,952 KB
実行使用メモリ 8,460 KB
最終ジャッジ日時 2023-09-16 12:49:33
合計ジャッジ時間 4,478 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,820 KB
testcase_01 AC 16 ms
7,920 KB
testcase_02 AC 490 ms
8,392 KB
testcase_03 AC 52 ms
7,800 KB
testcase_04 AC 23 ms
7,864 KB
testcase_05 WA -
testcase_06 AC 157 ms
8,272 KB
testcase_07 AC 109 ms
8,164 KB
testcase_08 AC 59 ms
7,916 KB
testcase_09 WA -
testcase_10 AC 16 ms
7,764 KB
testcase_11 AC 111 ms
8,192 KB
testcase_12 AC 361 ms
8,292 KB
testcase_13 AC 376 ms
8,340 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 441 ms
8,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
win = [-1]*(n+1)

pflag = [True]*(n+1)
primes = []

for i in range(2, n):
    if pflag[i]:
        primes.append(i)
        num = 2
        while i*num <= n:
            pflag[i*num] = False
            num += 1

win[2] = 0
win[3] = 0

for i in range(2, n+1):
    for prime in primes:
        if i-prime < 2:
            win[i] = 0
            break
        if win[i-prime] == 0:
            win[i] = 1
            break

if win[n] == 0:
    print("Lose")
else:
    print("Win")
0