結果

問題 No.7 プライムナンバーゲーム
ユーザー Woo-CieWoo-Cie
提出日時 2019-03-23 10:46:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 4,104 ms / 5,000 ms
コード長 730 bytes
コンパイル時間 135 ms
コンパイル使用メモリ 12,028 KB
実行使用メモリ 42,356 KB
最終ジャッジ日時 2023-10-22 00:39:34
合計ジャッジ時間 33,973 ms
ジャッジサーバーID
(参考情報)
judge9 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 472 ms
42,356 KB
testcase_01 AC 487 ms
42,356 KB
testcase_02 AC 4,104 ms
42,356 KB
testcase_03 AC 695 ms
42,356 KB
testcase_04 AC 523 ms
42,356 KB
testcase_05 AC 530 ms
42,356 KB
testcase_06 AC 1,534 ms
42,356 KB
testcase_07 AC 1,157 ms
42,356 KB
testcase_08 AC 786 ms
42,356 KB
testcase_09 AC 2,053 ms
42,356 KB
testcase_10 AC 467 ms
42,356 KB
testcase_11 AC 1,181 ms
42,356 KB
testcase_12 AC 3,081 ms
42,356 KB
testcase_13 AC 3,259 ms
42,356 KB
testcase_14 AC 4,099 ms
42,356 KB
testcase_15 AC 3,902 ms
42,356 KB
testcase_16 AC 3,635 ms
42,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# -*- coding: utf-8-*-
import numpy as np
def f(n, t, pn):
    flag = False
    for i in pn:
        if n-i < 0:
            continue
        if t[n-i] == 0:
            t[n-i] = f(n-i, t, pn)
        if t[n-i] == -1:
            flag = flag or True
    if flag:
        return 1
    else:
        return -1
if __name__ == '__main__':
    n = int(input())
    t = np.zeros((n+1))
    t[0] = 1
    t[1] = 1
    pn=[2]
    for L in range(3,n):
        chk=True
        for L2 in pn:
            if L%L2 == 0:
                chk=False
        if chk==True:
            pn.append(L)
    pn.sort()
    pn.reverse()
    a = f(n, t, pn)
    if a == 1:
        print("Win")
    elif a == -1:
        print("Lose")
0