본문 바로가기

백준(BOJ) 풀이

[백준 15649] N과 M(1)

def NM(lst,Plst,n):

    if n==0:

        for i in range(len(Plst)-1):

            print(Plst[i], end=" ")

        print(Plst[len(Plst)-1])

    else :

        for i in range(len(lst)):

            Nlst=[i for i in lst]

            NPlst=[i for i in Plst]

            Nlst.remove(lst[i])

            NPlst.append(lst[i])

            NM(Nlst,NPlst,n-1)

 

m,n=map(int, input().split())

lstA=[i+1 for i in range(m)]

NM(lstA,[],n)

'백준(BOJ) 풀이' 카테고리의 다른 글

[백준 2667] 단지 번호 붙이기  (0) 2019.11.12
[백준 1753] 최단경로  (0) 2019.11.12
[백준 17836] 공주님을 구해라  (0) 2019.11.10
[백준 1002] 터렛  (0) 2019.11.10
[백준 1914] 하노이 탑  (0) 2019.11.10