Title: K개 중에 1개를 N번 뽑기, Time: 218ms, Memory: 27MB, Status: Passed - Codetree

This commit is contained in:
SSUM
2025-05-14 20:51:34 +09:00
parent c4e4c33372
commit dea0b75183

View File

@@ -0,0 +1,21 @@
K, N = map(int, input().split())
# Please write your code here.
selected_nums = []
def print_permutation():
for num in selected_nums:
print(num, end = " ")
print()
def find_permutations(cnt):
if cnt == N:
print_permutation()
return
for i in range(1, K+1):
selected_nums.append(i)
find_permutations(cnt + 1)
selected_nums.pop()
find_permutations(0)