diff --git a/250514/K개 중에 1개를 N번 뽑기/n-permutations-of-k-with-repetition.py b/250514/K개 중에 1개를 N번 뽑기/n-permutations-of-k-with-repetition.py new file mode 100644 index 0000000..2721557 --- /dev/null +++ b/250514/K개 중에 1개를 N번 뽑기/n-permutations-of-k-with-repetition.py @@ -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) \ No newline at end of file