3560. Find Minimum Log Transportation Cost Easy
1/**
2 * [3560] Find Minimum Log Transportation Cost
3 *
4 * You are given integers n, m, and k.
5 * There are two logs of lengths n and m units, which need to be transported in three trucks where each truck can carry one log with length at most k units.
6 * You may cut the logs into smaller pieces, where the cost of cutting a log of length x into logs of length len1 and len2 is cost = len1 * len2 such that len1 + len2 = x.
7 * Return the minimum total cost to distribute the logs onto the trucks. If the logs don't need to be cut, the total cost is 0.
8 *
9 * <strong class="example">Example 1:
10 * <div class="example-block">
11 * Input: <span class="example-io">n = 6, m = 5, k = 5</span>
12 * Output: <span class="example-io">5</span>
13 * Explanation:
14 * Cut the log with length 6 into logs with length 1 and 5, at a cost equal to 1 * 5 == 5. Now the three logs of length 1, 5, and 5 can fit in one truck each.
15 * </div>
16 * <strong class="example">Example 2:
17 * <div class="example-block">
18 * Input: <span class="example-io">n = 4, m = 4, k = 6</span>
19 * Output: <span class="example-io">0</span>
20 * Explanation:
21 * The two logs can fit in the trucks already, hence we don't need to cut the logs.
22 * </div>
23 *
24 * Constraints:
25 *
26 * 2 <= k <= 10^5
27 * 1 <= n, m <= 2 * k
28 * The input is generated such that it is always possible to transport the logs.
29 *
30 */
31pub struct Solution {}
32
33// problem: https://leetcode.com/problems/find-minimum-log-transportation-cost/
34// discuss: https://leetcode.com/problems/find-minimum-log-transportation-cost/discuss/?currentPage=1&orderBy=most_votes&query=
35
36// submission codes start here
37
38impl Solution {
39 pub fn min_cutting_cost(n: i32, m: i32, k: i32) -> i64 {
40
41 }
42}
43
44// submission codes end
45
46#[cfg(test)]
47mod tests {
48 use super::*;
49
50 #[test]
51 fn test_3560() {
52 }
53}
54Back
© 2026 bowen.ge All Rights Reserved.