1201. Ugly Number III Medium
1/**
2 * [1201] Ugly Number III
3 *
4 * An ugly number is a positive integer that is divisible by a, b, or c.
5 * Given four integers n, a, b, and c, return the n^th ugly number.
6 *
7 * Example 1:
8 *
9 * Input: n = 3, a = 2, b = 3, c = 5
10 * Output: 4
11 * Explanation: The ugly numbers are 2, 3, 4, 5, 6, 8, 9, 10... The 3^rd is 4.
12 *
13 * Example 2:
14 *
15 * Input: n = 4, a = 2, b = 3, c = 4
16 * Output: 6
17 * Explanation: The ugly numbers are 2, 3, 4, 6, 8, 9, 10, 12... The 4^th is 6.
18 *
19 * Example 3:
20 *
21 * Input: n = 5, a = 2, b = 11, c = 13
22 * Output: 10
23 * Explanation: The ugly numbers are 2, 4, 6, 8, 10, 11, 12, 13... The 5^th is 10.
24 *
25 *
26 * Constraints:
27 *
28 * 1 <= n, a, b, c <= 10^9
29 * 1 <= a * b * c <= 10^18
30 * It is guaranteed that the result will be in range [1, 2 * 10^9].
31 *
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/ugly-number-iii/
36// discuss: https://leetcode.com/problems/ugly-number-iii/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41 pub fn nth_ugly_number(n: i32, a: i32, b: i32, c: i32) -> i32 {
42 0
43 }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50 use super::*;
51
52 #[test]
53 fn test_1201() {
54 }
55}
56
Back
© 2025 bowen.ge All Rights Reserved.