- 오랜 시간 고민했는데 중복을 제거해주는 방법을 몰라서 결국 구글링을 통해서 해결했다.
import heapq
import sys
input = sys.stdin.readline
K, N = map(int, input().strip().split())
li = list(map(int, input().strip().split()))
heap = []
for i in li:
heapq.heappush(heap, i)
for i in range(N):
num = heapq.heappop(heap)
for j in range(K):
temp = num * li[j]
heapq.heappush(heap, temp)
# 중복을 제거하는 방법(2×5나 5×2는 동일하므로)
if num % li[j] == 0:
break
else:
print(num)