3348. Smallest Divisible Digit Product II Hard

@problem@discussion
#Math#String#Backtracking#Greedy#Number Theory



1/**
2 * [3348] Smallest Divisible Digit Product II
3 *
4 * You are given a string num which represents a positive integer, and an integer t.
5 * A number is called zero-free if none of its digits are 0.
6 * Return a string representing the smallest zero-free number greater than or equal to num such that the product of its digits is divisible by t. If no such number exists, return "-1".
7 *  
8 * <strong class="example">Example 1:
9 * <div class="example-block">
10 * Input: <span class="example-io">num = "1234", t = 256</span>
11 * Output: <span class="example-io">"1488"</span>
12 * Explanation:
13 * The smallest zero-free number that is greater than 1234 and has the product of its digits divisible by 256 is 1488, with the product of its digits equal to 256.
14 * </div>
15 * <strong class="example">Example 2:
16 * <div class="example-block">
17 * Input: <span class="example-io">num = "12355", t = 50</span>
18 * Output: <span class="example-io">"12355"</span>
19 * Explanation:
20 * 12355 is already zero-free and has the product of its digits divisible by 50, with the product of its digits equal to 150.
21 * </div>
22 * <strong class="example">Example 3:
23 * <div class="example-block">
24 * Input: <span class="example-io">num = "11111", t = 26</span>
25 * Output: <span class="example-io">"-1"</span>
26 * Explanation:
27 * No number greater than 11111 has the product of its digits divisible by 26.
28 * </div>
29 *  
30 * Constraints:
31 * 
32 * 	2 <= num.length <= 2 * 10^5
33 * 	num consists only of digits in the range ['0', '9'].
34 * 	num does not contain leading zeros.
35 * 	1 <= t <= 10^14
36 * 
37 */
38pub struct Solution {}
39
40// problem: https://leetcode.com/problems/smallest-divisible-digit-product-ii/
41// discuss: https://leetcode.com/problems/smallest-divisible-digit-product-ii/discuss/?currentPage=1&orderBy=most_votes&query=
42
43// submission codes start here
44
45impl Solution {
46    pub fn smallest_number(num: String, t: i64) -> String {
47        String::new()
48    }
49}
50
51// submission codes end
52
53#[cfg(test)]
54mod tests {
55    use super::*;
56
57    #[test]
58    fn test_3348() {
59    }
60}
61


Back
© 2025 bowen.ge All Rights Reserved.