개발/Algorithm

[Python] 백준 15649번 N과 M (1)

Dane.Kim 2021. 11. 15.

itertools를 이용해 간단히 풀어보자

from itertools import permutations

N, M = map(int, input().split())
P = permutations(range(1, N + 1), M)  # iter(tuple)
for i in P:
    print(" ".join(map(str, i)))  # tuple -> str

댓글