Algorithm/Problems_Solving
-
백준(BaekJoon)_15657_N과 M(8)Algorithm/Problems_Solving 2022. 8. 27. 11:18
n,m = map(int, input().split()) num_list = list(map(int, input().split())) result = [] def func(idx): if len(result) == m: print(" ".join(map(str,result))) return else: num_list.sort() for idx in range(idx,len(num_list)): result.append(num_list[idx]) func(idx) result.pop() func(0)
-
백준(BaekJoon)_15656_N과 M(7)Algorithm/Problems_Solving 2022. 8. 27. 11:14
n,m = map(int, input().split()) num_list = list(map(int, input().split())) answer = [] def func(start): if m == len(answer): print(" ".join(map(str, answer))) else: num_list.sort() for i in range(start, n): answer.append(num_list[i]) func(0) answer.pop() func(0)
-
백준(BaekJoon)_15656_N과M(6)Algorithm/Problems_Solving 2022. 8. 27. 11:12
n,m = map(int, input().split()) num_list = list(map(int, input().split())) result = [] def func(start): if m == len(result): print(" ".join(map(str, result))) else: num_list.sort() for i in range(start, n): if num_list[i] not in result: result.append(num_list[i]) func(i) result.pop() func(0)
-
백준(BaekJoon)_15654_N과M(5)Algorithm/Problems_Solving 2022. 8. 23. 09:55
n, m = map(int, input().split()) num_list = list(map(int, input().split())) answer = [] def func(): if len(answer) == m: print(" ".join(map(str, answer))) else: num_list.sort() for i in range(len(num_list)): if num_list[i] not in answer: answer.append(num_list[i]) func() answer.pop() func()
-
백준(BaekJoon)_15651_N과M(3)Algorithm/Problems_Solving 2022. 8. 21. 12:48
# 15651 N과 M(1)은 중복이 허용되지 않는데, 여기서는 중복을 허용 (즉 자연수 n과 같은 수도 출력하는것) result = [] def func(n,m): if len(result) == m: print(" ".join(map(str, result))) else: for i in range(1,n+1): result.append(i) func(n,m) result.pop() n, m = map(int, input().split()) func(n,m)
-
백준(BaekJoon)_15650_N과 M(2)Algorithm/Problems_Solving 2022. 8. 21. 11:36
res = [] def func(n,m): if len(res) == m: test = res[:] test.sort() if (test == res): for ele in res: print(ele, end= " ") print() return else: for i in range(1,n+1): if i not in res: res.append(i) func(n,m) res.pop() n, m = map(int, input().split()) func(n,m) ========================================================== # 다른풀이 n,m = list(map(int,input().split())) result = [] def func(start): if m ..
-
백준(BaekJoon)_15649_N과M(1)Algorithm/Problems_Solving 2022. 8. 21. 11:33
result = [] def func(n,m): if len(result) == m: for i in result: print(i, end=" ") print() return else: for i in range(1,n+1): if i not in result: result.append(i) func(n,m) result.pop() n, m = map(int, input().split()) func(n,m) ================================================ cf. 같은 결과를 낸다 if len(result) == m: for i in result: print(i, end=" ") print() if len(result)==m: print(' '.join(map(str..