Tap here to switch tabs
Problem
Submissions

Problem: Ugly Number III

Try to solve the Ugly Number III problem.

Statement

An ugly number is defined as a positive integer that is divisible by a, b, or c.

Given four integers n, a, b, and c, return the nthn^{th} ugly number.

Constraints:

  • 1≤n,a,b,c≤1091 \leq n, a, b, c \leq 10^9

  • 1≤a×b×c≤10181 \leq a \times b \times c \leq 10^{18}

  • The result is guaranteed to be in the range [1,2×109][1, 2 \times 10^9].

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Ugly Number III

Try to solve the Ugly Number III problem.

Statement

An ugly number is defined as a positive integer that is divisible by a, b, or c.

Given four integers n, a, b, and c, return the nthn^{th} ugly number.

Constraints:

  • 1≤n,a,b,c≤1091 \leq n, a, b, c \leq 10^9

  • 1≤a×b×c≤10181 \leq a \times b \times c \leq 10^{18}

  • The result is guaranteed to be in the range [1,2×109][1, 2 \times 10^9].