human
Super Ugly Number ( Number whose prime factors are in given set ) | function will return the nth super ugly number.
n cannot be negative hence return - 1 if n is 0 or - ve.
Declare a min heap priority queue.
Push all the array elements to priority queue.
once count = n we return no.
sorted ( pq ) Get the minimum value from priority_queue.
If top of pq is no then don 't increment count.  This to avoid duplicate counting of same no..
Push all the multiples of no . to priority_queue.
cnt += 1.
Return nth super ugly number.
Driver program to test above functions"
Solution in Python:
assistant
#Here is code to super Ugly Number ( Number whose prime factors are in given set ) and the other steps required.
 def ugly ( a , size , n ) :
	if ( n <= 0 ) :
		return - 1
	if ( n == 1 ) :
		return 1
	pq = [ ]
	for i in range ( size ) :
		pq . append ( a [ i ] )
	count = 1
	no = 0
	pq = sorted ( pq )
	while ( count < n ) :
		no = pq [ 0 ]
		del pq [ 0 ]
		if ( no != pq [ 0 ] ) :
			count += 1
			for i in range ( size ) :
				pq . append ( no * a [ i ] )
		pq = sorted ( pq )
	return no
if __name__ == ' _ _ main _ _ ' :
	a = [ 2 , 3 , 5 ]
	size = len ( a )
	print ( ugly ( a , size , 1000 ) )