[파이썬]백준 15649 N과 M(3)

Byeonghyeon Kim·2021년 3월 5일
0

알고리즘문제

목록 보기
27/93
post-thumbnail

링크

백준 15649 N과 M(3)


순열문제


정답 코드

def perm(idx):
    if idx == M:
        print(' '.join(map(str, sel)))
    else:
        for i in range(N):
            sel[idx] = arr[i]
            perm(idx + 1)

N, M = map(int, input().split())
arr = [i for i in range(1, N + 1)]
sel = [0] * M

perm(0)

알게된 것👨‍💻

  • Permutation!
profile
자기 주도 개발전 (개발, 발전)

0개의 댓글