Files
baekjoon-study/workbook_8708/gold/7490-g5.py
2026-02-23 14:10:12 +09:00

39 lines
583 B
Python

# 0 만들기
import sys
from collections import deque
input = sys.stdin.readline
OPERATOR = [" ", "+", "-"] # 아스키 순서
def dfs(depth, n, exp):
if depth == n:
exp += str(depth)
if eval(exp.replace(" ", "")) == 0:
print(exp)
return
for op in OPERATOR:
dfs(depth+1, n, exp+str(depth)+op)
def solution():
t = int(input().rstrip())
for _ in range(t):
n = int(input().rstrip())
dfs(1, n, "")
print()
return
solution()
"""
걸린 시간: 11:18~
시간 복잡도:
해설:
"""