1015. Smallest Integer Divisible by K Medium
1/**
2 * [1015] Smallest Integer Divisible by K
3 *
4 * Given a positive integer k, you need to find the length of the smallest positive integer n such that n is divisible by k, and n only contains the digit 1.
5 * Return the length of n. If there is no such n, return -1.
6 * Note: n may not fit in a 64-bit signed integer.
7 *
8 * Example 1:
9 *
10 * Input: k = 1
11 * Output: 1
12 * Explanation: The smallest answer is n = 1, which has length 1.
13 *
14 * Example 2:
15 *
16 * Input: k = 2
17 * Output: -1
18 * Explanation: There is no such positive integer n divisible by 2.
19 *
20 * Example 3:
21 *
22 * Input: k = 3
23 * Output: 3
24 * Explanation: The smallest answer is n = 111, which has length 3.
25 *
26 *
27 * Constraints:
28 *
29 * 1 <= k <= 10^5
30 *
31 */
32pub struct Solution {}
33
34// problem: https://leetcode.com/problems/smallest-integer-divisible-by-k/
35// discuss: https://leetcode.com/problems/smallest-integer-divisible-by-k/discuss/?currentPage=1&orderBy=most_votes&query=
36
37// submission codes start here
38
39impl Solution {
40 pub fn smallest_repunit_div_by_k(k: i32) -> i32 {
41 0
42 }
43}
44
45// submission codes end
46
47#[cfg(test)]
48mod tests {
49 use super::*;
50
51 #[test]
52 fn test_1015() {
53 }
54}
55
Back
© 2025 bowen.ge All Rights Reserved.