15651: N과 M (3)

ewillwin·2023년 4월 28일
0

Problem Solving (BOJ)

목록 보기
22/230

import sys

N, M = map(int, input().split(' '))
ans = []

def dfs():
    if len(ans) == M:
        print(" ".join(map(str, ans)))
        return
    for i in range(1, N+1):
        ans.append(i)
        dfs()
        ans.pop()

dfs()
  • 같은 수를 여러 번 고를 수 있도록 구현
profile
Software Engineer @ LG Electronics

0개의 댓글