結果
問題 | No.10 +か×か |
ユーザー |
|
提出日時 | 2021-02-05 08:15:15 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 712 ms / 5,000 ms |
コード長 | 488 bytes |
コンパイル時間 | 154 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 75,344 KB |
最終ジャッジ日時 | 2024-12-14 15:47:10 |
合計ジャッジ時間 | 2,502 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 |
ソースコード
from collections import deque N = int(input()) T = int(input()) A = tuple(map(int, input().split())) stk = deque() visited = set() def rec(i, x): if (i, x) in visited: return 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() visited.add((i, x)) rec(1, A[0])