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

Python Code
from itertools import combinations_with_replacement #중복 조합
N, M = map(int, input().split())
N_list = list(map(int, input().split()))
N_list = sorted(N_list) #순서대로 나오게 정렬 먼저
output = []
for numbers in list(combinations_with_replacement(N_list, M)):
if not output:
output.append(numbers)
elif numbers not in output:
output.append(numbers)
for numbers in output:
for num in numbers:
print(num, end=' ')
print() 'Programming [Python] > 백준 알고리즘 솔루션' 카테고리의 다른 글
| #260 백준 파이썬 [15663] N과 M (9) - 순열 (0) | 2019.12.04 |
|---|---|
| #259 백준 파이썬 [15665] N과 M (11) - 중복 순열 (0) | 2019.12.04 |
| #257 백준 파이썬 [15664] N과 M (10) - 조합 (0) | 2019.12.04 |
| #256 백준 파이썬 [15657] N 과 M (8) - 중복조합 (0) | 2019.12.04 |
| #255 백준 파이썬 [15664] N과 M (7) - 중복 순열 (0) | 2019.12.04 |