📌문제
https://www.acmicpc.net/problem/15650
🎖️난이도
✔️풀이
n, m = map(int, input().split())
result = []
def dfs(k):
if len(result) == m:
print(' '.join(map(str, result)))
for i in range(k, n+1):
if i not in result:
result.append(i)
dfs(i+1) # 다음 값부터 dfs 돌도록 넣기!
result.pop()
dfs(1)
'[ 알고리즘 ] > Back Tracking' 카테고리의 다른 글
[백준] 9663. N-Queen (0) | 2022.06.30 |
---|---|
[백준] 15651. N과 M (3) (0) | 2022.06.30 |
[백준] 15649. N과 M (1) (0) | 2022.06.30 |