Super Ugly Number
medium
1. You are given an array(arr) of size k which contains prime numbers in ascending order, and an integer N. 2. You have to find Nth super ugly number. 3. Super ugly number is defined as the number whose prime factors are elements of the given array. Assumption -> 1 is the first super ugly number.
Constraints
1 <= K <= 100 1 <= arr[i] <= 1000 1 <= N <= 10^6
Format
Input
A number K arr1 arr2.. K prime numbers in ascending order A number N
Output
A number representing Nth super ugly number.
Example
Sample Input
4
3 5 7 11
13
Sample Output
45