結果
| 問題 | No.10 +か×か |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-06-12 15:54:48 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 441 ms / 5,000 ms |
| コード長 | 488 bytes |
| 記録 | |
| コンパイル時間 | 197 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 124,932 KB |
| 最終ジャッジ日時 | 2025-12-06 15:00:26 |
| 合計ジャッジ時間 | 2,221 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 |
ソースコード
n = int(input())
x = int(input())
A = list(map(int, input().split()))
ope = []
memo = set()
def dfs(t, tot):
if t == n:
if tot == x:
print(*ope, sep="")
exit()
return
if t + tot * n in memo:
return
if tot + A[t] <= x:
ope.append("+")
dfs(t + 1, tot + A[t])
ope.pop()
if tot * A[t] <= x:
ope.append("*")
dfs(t + 1, tot * A[t])
ope.pop()
memo.add(t + tot * n)
dfs(1, A[0])