結果

問題 No.7 プライムナンバーゲーム
ユーザー Woo-CieWoo-Cie
提出日時 2019-03-23 10:42:26
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
RE  
実行時間 -
コード長 696 bytes
コンパイル時間 530 ms
コンパイル使用メモリ 11,764 KB
実行使用メモリ 42,400 KB
最終ジャッジ日時 2023-10-22 00:35:30
合計ジャッジ時間 18,299 ms
ジャッジサーバーID
(参考情報)
judge9 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 476 ms
42,396 KB
testcase_01 AC 496 ms
42,396 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 520 ms
42,396 KB
testcase_05 AC 515 ms
42,396 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 474 ms
42,396 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
権限があれば一括ダウンロードができます

ソースコード

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:
            break
        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)
    a = f(n, t, pn)
    if a == 1:
        print("Win")
    elif a == -1:
        print("Lose")
0