結果

問題 No.7 プライムナンバーゲーム
ユーザー 8080
提出日時 2018-09-06 00:49:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 510 ms / 5,000 ms
コード長 723 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-09 04:31:51
合計ジャッジ時間 4,509 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,752 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 496 ms
10,880 KB
testcase_03 AC 58 ms
10,752 KB
testcase_04 AC 40 ms
10,752 KB
testcase_05 AC 37 ms
10,752 KB
testcase_06 AC 163 ms
10,880 KB
testcase_07 AC 120 ms
10,880 KB
testcase_08 AC 68 ms
10,880 KB
testcase_09 AC 234 ms
10,880 KB
testcase_10 AC 29 ms
10,752 KB
testcase_11 AC 120 ms
10,880 KB
testcase_12 AC 377 ms
11,008 KB
testcase_13 AC 380 ms
10,880 KB
testcase_14 AC 510 ms
11,008 KB
testcase_15 AC 484 ms
11,008 KB
testcase_16 AC 448 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False

    for i in range(2,n + 1) :
        if is_prime[i]:
            for j in range(2 * i,n + 1,i):
                is_prime[j]=False
    return [i for i in range(n + 1) if is_prime[i]]

n = int(input())
sosu = primes(n)
#判定(0,1,2)
lst = [False,False,True]
hantei = True

if n>3:
    for i in range(3,n+1):
        for j in sosu:
            k = i-j
            if k<0:
                lst.append(True)
                break
            if lst[k]:
                lst.append(False)
                break
        else:
            lst.append(True)
    hantei = lst[n]

print("Lose" if hantei else "Win")
0