1부터 N까지 자연수 중 중복 없이 M개를 고른 수열의 집합
-> Combination (조합)
파이썬 라이브러리 itertools의 combinations을 이용하여 손쉽게 풀 수 있는 문제.
from itertools import combinations
n, m = map(int, input().split())
data = [i for i in range(1, n + 1)]
for i in combinations(data, m):
for j in i:
print(j, end=' ')
print()
'백준 알고리즘 (Baekjoon Algorithm)' 카테고리의 다른 글
[파이썬] 백준 알고리즘 No.15652 N과 M (4) (0) | 2021.12.15 |
---|---|
[파이썬] 백준 알고리즘 No.15651 N과 M (3) (0) | 2021.12.15 |
[파이썬] 백준 알고리즘 No.1002 터렛 (0) | 2021.12.14 |
[파이썬] 백준 알고리즘 No.9020 골드바흐의 추측 (0) | 2021.12.14 |
[파이썬] 백준 알고리즘 No.4948 베르트랑 공준 (0) | 2021.12.10 |