結果

問題 No.7 プライムナンバーゲーム
ユーザー Woo-CieWoo-Cie
提出日時 2019-03-23 11:01:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,375 ms / 5,000 ms
コード長 740 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 43,848 KB
最終ジャッジ日時 2024-04-09 04:36:18
合計ジャッジ時間 18,148 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 518 ms
43,608 KB
testcase_01 AC 522 ms
43,720 KB
testcase_02 AC 1,333 ms
43,736 KB
testcase_03 AC 573 ms
43,592 KB
testcase_04 AC 531 ms
43,608 KB
testcase_05 AC 536 ms
43,596 KB
testcase_06 AC 767 ms
43,844 KB
testcase_07 AC 671 ms
43,576 KB
testcase_08 AC 600 ms
43,704 KB
testcase_09 AC 887 ms
43,600 KB
testcase_10 AC 525 ms
43,848 KB
testcase_11 AC 674 ms
43,492 KB
testcase_12 AC 1,192 ms
43,588 KB
testcase_13 AC 1,178 ms
43,720 KB
testcase_14 AC 1,352 ms
43,572 KB
testcase_15 AC 1,375 ms
43,848 KB
testcase_16 AC 1,317 ms
43,596 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 = True
            break
    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