class Solution(object):
def nthUglyNumber(self, n):
"""
:type n: int
:rtype: int
"""
h=[(1,1)]
for _ in xrange(n):
val,fact=heapq.heappop(h)
for x in [2,3,5]:
if fact<=x:
heapq.heappush(h,(val*x,x))
return val