Skip to content

Commit 3f35c28

Browse files
authored
Merge pull request #1647 from AlgorithmWithGod/khj20006
[20251211] BOJ / G5 / 0 만들기 / 권혁준
2 parents f96c08c + 223b2fc commit 3f35c28

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
```python
2+
def bck(cur, tar, expr, op):
3+
if cur == tar and op == True:
4+
if eval(expr.replace(' ', '')) == 0:
5+
print(expr)
6+
return
7+
if op == True:
8+
bck(cur+1, tar, expr+" ", False)
9+
bck(cur+1, tar, expr+"+", False)
10+
bck(cur+1, tar, expr+"-", False)
11+
else:
12+
bck(cur, tar, expr+str(cur), True)
13+
14+
for _ in range(int(input())):
15+
bck(1, int(input()), "", False)
16+
print()
17+
```

0 commit comments

Comments
 (0)