15650. N과 M (2)

멍진이·2021년 6월 8일
0

백준 문제풀기

목록 보기
3/36

문제 링크

링크텍스트

문제 코드

from itertools import combinations

num_list = list(map(int, input().split()))

N=num_list[0]
M = num_list[1]

num_list =[]
for i in range(1,N+1):
    num_list.append(i)

total_list= list(combinations(num_list,M))

for tmp in total_list:
    result_string = ""

    for i in range(len(tmp)):
        result_string+=str(tmp[i])+" "

    print(result_string)

문제 풀이

  • 조합을 물어보는 문제여서 combination 씀

  • itertool을 안쓸 경우 combination 구현 필요

profile
개발하는 멍멍이

0개의 댓글