BOJ/백준-15652-python

cosmos·2022년 10월 7일
0
post-thumbnail
post-custom-banner

문제

코드

# https://www.acmicpc.net/problem/15652
# boj, 15652: n과 m (4), python3
import sys

input = sys.stdin.readline

def solve(n: int, m: int, graph: list, start: int):
    if len(graph) == m:
        print(' '.join(map(str, graph)))
        return

    for x in range(start, n+1):
        graph.append(x)
        solve(n, m, graph, x)
        graph.pop()

if __name__ == '__main__':
    n, m = map(int, input().split())
    graph = []

    solve(n, m, graph, 1)

결과

출처 & 깃허브

boj 15652
github

post-custom-banner

0개의 댓글