Redirecting to
NADOS

Super Ugly Number

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.
Input Format
A number K
arr1
arr2.. K prime numbers in ascending order
A number N
Output Format
A number representing Nth super ugly number.
Question Video
Constraints
1 <= K <= 100
1 <= arr[i] <= 1000
1 <= N <= 10^6
Sample Input
4
3 5 7 11
13
Sample Output
45


  • Asked in Companies
  • Related Topics






Video Solution

Code Solution

Run
 
Run
Id Name