結果
| 問題 | No.10 +か×か |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2026-01-02 01:34:00 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 513 ms / 5,000 ms |
| コード長 | 505 bytes |
| 記録 | |
| コンパイル時間 | 345 ms |
| コンパイル使用メモリ | 82,780 KB |
| 実行使用メモリ | 182,548 KB |
| 最終ジャッジ日時 | 2026-01-02 01:34:03 |
| 合計ジャッジ時間 | 3,333 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 |
ソースコード
N = int(input())
T = int(input())
A = list(map(int, input().split()))
memo = {}
def dfs(p, s, ops) -> bool:
if s > T: return False
if p == N:
if s == T:
print(''.join(ops))
return True
return False
if (p, s) in memo:
return False
memo[p, s] = True
ops[p] = '+'
if dfs(p+1, s+A[p], ops):
return True
ops[p] = '*'
if dfs(p+1, s*A[p], ops):
return True
return False
ops = [''] * N
dfs(1, A[0], ops)
norioc