3669. Balanced K-Factor Decomposition Medium
1/**
2 * [3669] Balanced K-Factor Decomposition
3 *
4 * Given two integers n and k, split the number n into exactly k positive integers such that the product of these integers is equal to n.
5 * Return any one split in which the maximum difference between any two numbers is minimized. You may return the result in any order.
6 *
7 * <strong class="example">Example 1:
8 * <div class="example-block">
9 * Input: <span class="example-io">n = 100, k = 2</span>
10 * Output: <span class="example-io">[10,10]</span>
11 * Explanation:
12 * <p data-end="157" data-start="0">The split [10, 10] yields 10 * 10 = 100 and a max-min difference of 0, which is minimal.
13 * </div>
14 * <strong class="example">Example 2:
15 * <div class="example-block">
16 * Input: <span class="example-io">n = 44, k = 3</span>
17 * Output: <span class="example-io">[2,2,11]</span>
18 * Explanation:
19 *
20 * <li data-end="46" data-start="2">Split [1, 1, 44] yields a difference of 43
21 * <li data-end="93" data-start="49">Split [1, 2, 22] yields a difference of 21
22 * <li data-end="140" data-start="96">Split [1, 4, 11] yields a difference of 10
23 * <li data-end="186" data-start="143">Split [2, 2, 11] yields a difference of 9
24 *
25 * <p data-end="264" data-is-last-node="" data-is-only-node="" data-start="188">Therefore, [2, 2, 11] is the optimal split with the smallest difference 9.
26 * </div>
27 *
28 * Constraints:
29 *
30 * <li data-end="54" data-start="37"><code data-end="52" data-start="37">4 <= n <= 10^<span style="font-size: 10.8333px;">5</span>
31 * <li data-end="71" data-start="57"><code data-end="69" data-start="57">2 <= k <= 5
32 * <li data-end="145" data-is-last-node="" data-start="74"><code data-end="77" data-start="74">k is strictly less than the total number of positive divisors of <code data-end="144" data-is-only-node="" data-start="141">n.
33 *
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/balanced-k-factor-decomposition/
38// discuss: https://leetcode.com/problems/balanced-k-factor-decomposition/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43 pub fn min_difference(n: i32, k: i32) -> Vec<i32> {
44 vec![]
45 }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 #[test]
55 fn test_3669() {
56 }
57}
58Back
© 2026 bowen.ge All Rights Reserved.