본문 바로가기

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

#259 백준 파이썬 [15665] N과 M (11) - 중복 순열

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

 

Python Code

from itertools import product

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

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