728x90
비내림차순이라고 하는 이유가 같은 수가 있어서 그런거였구나..
from itertools import combinations_with_replacement
N,M=map(int,input().split())
numlist=map(str,range(1,N+1))
setlist=list(combinations_with_replacement(numlist,M))
print('\n'.join(list(map(' '.join,setlist))))
itertools 라이브러리에서 조합과 순열 관련한 함수들을 모조리 다 써보는 문제였군.
이 라이브러리를 몰랐다면,, 아마 답답함에 몸부림 쳤을 듯 싶다.
이번에는 combinations_with_replace(arr,n) 함수를 써서 풀었다.
아주 유익한 라이브러리인 것 같다.
728x90
'Baekjoon Case' 카테고리의 다른 글
[백준 #2580] 스도쿠 - 파이썬(python) (0) | 2021.08.16 |
---|---|
[백준 #9663] N-Queen - 파이썬 (python) (0) | 2021.08.15 |
[백준 #15651] N과 M(3) - 파이썬(python) (0) | 2021.08.14 |
[백준 #15650] N과 M(2) - 파이썬(python) (0) | 2021.08.14 |
[백준 #15649] N과 M(1) - 파이썬(python) (0) | 2021.08.13 |