Study/알고리즘
[백준] 15652번_N과M(4)
혤리
2020. 1. 29. 14:24
문제 링크 : https://www.acmicpc.net/problem/15652
15652번: N과 M (4)
한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안되며, 각 수열은 공백으로 구분해서 출력해야 한다. 수열은 사전 순으로 증가하는 순서로 출력해야 한다.
www.acmicpc.net
from itertools import combinations_with_replacement
n,m = map(int,input().split())
comb = combinations_with_replacement(range(1,n+1),m)
for c in comb:
print(' '.join(map(str,c)))
중복조합 : combinations_with_replacement