結果

問題 No.7 プライムナンバーゲーム
ユーザー Mr.FukuMr.Fuku
提出日時 2018-06-25 22:23:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 555 ms / 5,000 ms
コード長 714 bytes
コンパイル時間 414 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-09 04:30:43
合計ジャッジ時間 5,168 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 29 ms
10,752 KB
testcase_02 AC 527 ms
11,008 KB
testcase_03 AC 60 ms
10,752 KB
testcase_04 AC 37 ms
10,624 KB
testcase_05 AC 38 ms
10,752 KB
testcase_06 AC 170 ms
10,752 KB
testcase_07 AC 124 ms
10,880 KB
testcase_08 AC 73 ms
10,752 KB
testcase_09 AC 243 ms
10,752 KB
testcase_10 AC 30 ms
10,752 KB
testcase_11 AC 131 ms
10,752 KB
testcase_12 AC 382 ms
10,880 KB
testcase_13 AC 398 ms
11,008 KB
testcase_14 AC 555 ms
10,880 KB
testcase_15 AC 501 ms
11,008 KB
testcase_16 AC 453 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, 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)
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