알고리즘/백준 문제풀이
[boj] 백준 15666 N과 M (12) python 풀이
감자156
2023. 8. 3. 13:30
반응형
문제
https://www.acmicpc.net/problem/15666
문제 풀이
백트래킹 기본
코드
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
LIST = sorted(list(set(map(int,input().split()))))
total = []
def back(s):
if len(total) == M:
print(*total)
return
for i in range(s,len(LIST)):
total.append(LIST[i])
back(i)
total.pop()
back(0)
반응형