結果

問題 No.10 +か×か
ユーザー H3PO4H3PO4
提出日時 2021-02-05 00:18:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 448 bytes
コンパイル時間 74 ms
コンパイル使用メモリ 10,948 KB
実行使用メモリ 13,052 KB
最終ジャッジ日時 2023-09-13 20:49:19
合計ジャッジ時間 8,427 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,712 KB
testcase_01 AC 20 ms
8,592 KB
testcase_02 AC 20 ms
8,732 KB
testcase_03 AC 528 ms
8,676 KB
testcase_04 AC 70 ms
8,588 KB
testcase_05 AC 20 ms
8,556 KB
testcase_06 AC 740 ms
8,664 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
from functools import lru_cache

N = int(input())
T = int(input())
A = tuple(map(int, input().split()))
stk = deque()

@lru_cache
def rec(i, x):
    if i == N and x == T:
        res = ''.join(map(str, stk))
        print(res)
        exit()
    elif i == N or x > T:
        return

    stk.append('+')
    rec(i + 1, x + A[i])
    stk.pop()

    stk.append('*')
    rec(i + 1, x * A[i])
    stk.pop()


rec(1, A[0])
0