# k, n 입력
k, n = map(int, input().split())
# 함수들
# print_ans()
def print_ans():
for num in ans_list:
print(num, end=' ')
print()
# choose(curr_idx)
def choose(curr_idx):
# 종료조건
if curr_idx == n + 1:
# 출력
print_ans()
return
# 넣어주기
for i in range(1, k+1):
# 넣고
ans_list.append(i)
# 다음자리로
choose(curr_idx + 1)
# 빼주기
ans_list.pop()
# 설계
# ans_list
ans_list = []
# choose
choose(1)
'Algorithm(CodeTree, Python) > Backtracking' 카테고리의 다른 글
[코드트리] 특정 조건에 맞게 k개 중에 1개를 n번 뽑기 Python (0) | 2023.01.30 |
---|---|
[코드트리] 알파벳과 사칙연산 Python (0) | 2023.01.29 |
[코드트리] 겹치지 않게 선분 고르기 Python (0) | 2023.01.28 |
[코드트리] 아름다운 수 Python (0) | 2023.01.28 |
[코드트리] 강력한 폭발 Python (0) | 2023.01.27 |