------
## 最终结论
```python
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

def lcm(x, y):
    return x * (y // gcd(x, y))

def count_ugly_numbers(mid, a, b, c):
    ab = lcm(a, b)
    ac = lcm(a, c)
    bc = lcm(b, c)
    abc = lcm(ab, c)
    
    count = (mid // a) + (mid // b) + (mid // c)
    count -= (mid // ab) + (mid // ac) + (mid // bc)
    count += (mid // abc)
    
    return count

def nth_ugly_number(n, a, b, c):
    left, right = 1, 2 * 10**9
    
    while left < right:
        mid = (left + right) // 2
        if count_ugly_numbers(mid, a, b, c) < n:
            left = mid + 1
        else:
            right = mid
            
    return left

# Example usage:
print(nth_ugly_number(3, 2, 3, 5))  # Output: 4
print(nth_ugly_number(4, 2, 3, 4))  # Output: 6
print(nth_ugly_number(5, 2, 11, 13)) # Output: 10
print(nth_ugly_number(1000000000, 2, 217983653, 336916467)) # Output: 1999999984
```