문제풀이/백준(Boj) 문제풀이
[백준(Boj)][14단계] 15652.N과 M (4) (파이썬/Python)
얄루몬
2021. 9. 5. 23:20
n, m = map(int,input().split())
result = []
def dfs(start):
#append된 값들이 m값만큼 들어와 있다면 출력
if len(result) == m:
print(' '.join(map(str,result)))
return
for i in range(start, n+1):
result.append(i)
#가지치기 작업
dfs(i)
result.pop()
dfs(1)