1class Solution:2def nthUglyNumber(self, n: int, a: int, b: int, c: int) -> int:3times = [1, 1, 1]4smallest = inf5while n != 0:6smallest = min(times[0] * a, times[1] * b, times[2] * c)7if times[0] * a == smallest:8times[0] += 19if times[1] * b == smallest:10times[1] += 111if times[2] * c == smallest:12times[2] += 113n -= 114return smallest