백준 15650 - N과 M (2) (파이썬)

Updated:

Answer

a, b = map(int, input().split())

def permutations(array, r):
    for i in range(len(array)):
        if r == 1:
            yield [array[i]]
        else:
            for next in permutations(array[i + 1:], r - 1):
                yield [array[i]] + next
                
c = list(permutations(list(i for i in range(1, a + 1)), b))

for i in c:
    print(*i)

Categories:

Updated: