(파이썬) 백준 알고리즘 15650번 N과 M(2)
문제풀이 (Python) 123456789101112131415161718import sysn,m = map(int,input().split())c = [False]*(n+1)a = [0]*m def go(index, start, n, m): if index == m: sys.stdout.write(' '.join(map(str,a))+'\n') for i in range(start, n+1): if c[i]: continue c[i] = True a[index] = i go(index+1, i+1, n, m) c[i] = False go(0,1,n,m) Colored by Color Scriptercs 1. 재귀 함수를 사용하여 수열을 만듦2. 중복이 불가능 하기 때문에 check를 사용하여 True이..
(파이썬) 백준 알고리즘 15649 번 N과 M(1)
문제풀이 (Python) 12345678910111213141516171819202122n,m = map(int,input().split()) check = [False]*(n+1)a = [0]*m def go(index, n, m): if index == m: for i in range(m): print (a[i], end = ' ') print() return for i in range(1, n+1): if check[i]: continue check[i] = True a[index] = i go(index+1, n, m) check[i] = False go(0,n,m) Colored by Color Scriptercs 1. 재귀 함수를 사용하여 수열을 만듦2. 중복이 불가능 하기 때문에 check를..