結果

問題 No.10 +か×か
コンテスト
ユーザー H3PO4
提出日時 2021-02-05 00:18:12
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 448 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 323 ms
コンパイル使用メモリ 20,956 KB
実行使用メモリ 30,644 KB
最終ジャッジ日時 2026-03-21 23:38:53
合計ジャッジ時間 9,346 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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