Write a program to find the nth
super ugly number.
Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes
of size k
.
Example:
Input: n = 12,primes
=[2,7,13,19]
Output: 32 Explanation:[1,2,4,7,8,13,14,16,19,26,28,32]
is the sequence of the first 12 super ugly numbers givenprimes
=[2,7,13,19]
of size 4.
Note:
<li><code>1</code> is a super ugly number for any given <code>primes</code>.</li>
<li>The given numbers in <code>primes</code> are in ascending order.</li>
<li>0 < <code>k</code> ≤ 100, 0 < <code>n</code> ≤ 10<sup>6</sup>, 0 < <code>primes[i]</code> < 1000.</li>
<li>The n<sup>th</sup> super ugly number is guaranteed to fit in a 32-bit signed integer.</li>