본문 바로가기

Programming [Python]/백준 알고리즘 솔루션

#250 백준 파이썬 [15654] N과 M (5) - 순열

https://www.acmicpc.net/problem/15654

 

Python Code

from itertools import permutations

N, M = map(int, input().split())
N_list = list(map(int, input().split()))
N_list = sorted(N_list) #순서대로 나오게 정렬 먼저

for numbers in list(permutations(N_list, M)):
    for num in numbers:
        print(num, end=' ')
    print()