[알고리즘/백준] 15656: N과 M(7)(python)

유현민·2022년 4월 27일
0

알고리즘

목록 보기
143/253

이번에는 중복이 가능하기 때문에 길이만 체크 해준다.

def dfs():
    if len(q) == M:
        print(' '.join(map(str, q)))
        return

    for i in range(N):
        q.append(a[i])
        dfs()
        q.pop()


q = []
N, M = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
dfs()
profile
smilegate megaport infra

0개의 댓글