結果

問題 No.7 プライムナンバーゲーム
ユーザー Woo-CieWoo-Cie
提出日時 2019-03-23 10:45:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 727 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 11,984 KB
実行使用メモリ 42,348 KB
最終ジャッジ日時 2023-10-22 00:38:26
合計ジャッジ時間 16,403 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 401 ms
42,348 KB
testcase_01 WA -
testcase_02 AC 1,143 ms
42,348 KB
testcase_03 AC 440 ms
42,348 KB
testcase_04 AC 434 ms
42,348 KB
testcase_05 WA -
testcase_06 AC 597 ms
42,348 KB
testcase_07 AC 535 ms
42,348 KB
testcase_08 AC 476 ms
42,348 KB
testcase_09 WA -
testcase_10 AC 403 ms
42,348 KB
testcase_11 AC 538 ms
42,348 KB
testcase_12 AC 881 ms
42,348 KB
testcase_13 AC 990 ms
42,348 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1,034 ms
42,348 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:
            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)
    pn.sort()
    pn.reverse()
    a = f(n, t, pn)
    if a == 1:
        print("Win")
    elif a == -1:
        print("Lose")
0