3790. Smallest All-Ones Multiple Medium

@problem@discussion
#Hash Table#Math



1/**
2 * [3790] Smallest All-Ones Multiple
3 *
4 * You are given a positive integer k.
5 * Find the smallest integer n divisible by k that consists of only the digit 1 in its decimal representation (e.g., 1, 11, 111, ...).
6 * Return an integer denoting the number of digits in the decimal representation of n. If no such n exists, return -1.
7 *  
8 * <strong class="example">Example 1:
9 * <div class="example-block">
10 * Input: <span class="example-io">k = 3</span>
11 * Output: <span class="example-io">3</span>
12 * Explanation:
13 * n = 111 because 111 is divisible by 3, but 1 and 11 are not. The length of n = 111 is 3.
14 * </div>
15 * <strong class="example">Example 2:
16 * <div class="example-block">
17 * Input: <span class="example-io">k = 7</span>
18 * Output: <span class="example-io">6</span>
19 * Explanation:
20 * n = 111111. The length of n = 111111 is 6.
21 * </div>
22 * <strong class="example">Example 3:
23 * <div class="example-block">
24 * Input: <span class="example-io">k = 2</span>
25 * Output: <span class="example-io">-1</span>
26 * Explanation:
27 * There does not exist a valid n that is a multiple of 2.
28 * </div>
29 *  
30 * Constraints:
31 * 
32 * 	2 <= k <= 10^5
33 * 
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/smallest-all-ones-multiple/
38// discuss: https://leetcode.com/problems/smallest-all-ones-multiple/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43    pub fn min_all_one_multiple(k: i32) -> i32 {
44        0
45    }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52    use super::*;
53
54    #[test]
55    fn test_3790() {
56    }
57}
58

Back
© 2026 bowen.ge All Rights Reserved.