Solutions cut the rope (an integer division) problem

Subject description:

      Has a length n of the rope, the rope now want to cut a long segment integers m (m, n are integers, n> 1 and m> 1), the length of each rope is referred to as k [0], k [ 1], ..., k [m ]. Q k [0] * k [1 ] * ... * k [m] maximum possible product is how much? For example, when the rope length is 8, the length of each cut it into three sections 2, 3, 3, the product obtained at this time is the maximum 18.

analysis of idea:

    1. Determine the range of k [i] is.

     If k [i] = 1, this time k [0] * k [1] * ... * k [i] * k [m] = k [0] * k [1] * ... * k [ m] is clearly less than k [0] * k [1] * ... * (k [i] + k [m]) = k [0] * k [1] * ... * k [m] + k [0] * k [1] * ... * k [i], i.e., k [0], k [1], ..., k [i], k [m] is less than the product of k [0] , k [1], ..., (k [i] + k [m]) of the product, so k [i] should take 1, should be taken greater than 1, but when n = 2, to meet the m> 1, only this time two cut 1,1; if n = 3, then cut into two sections only 1, 2.

      If k [i]> = 5, as k [i] = 5, case k [0] * k [1] * ... * k [i] * k [m] = k [0] * k [ 1] * ... * 5 * k [m] is clearly less than k [0] * k [1] * ... * (2 + 3) * k [m] = k [0] * k [1] * .... * 6 * k [m], by the inequality x ^ 2 + x> 2x + 1 with x any of the known> 5, x can always be divided into at least two numbers x1, x2 x1 * x2 so > x.

     When k [i] = 4, the case k [i] is divided into two, then the final result is equal to 2.

     To sum up, k [i] can only select out the value in {1, 2, 3} in.

   2. Problem Solution:

     The method defined shear line segment n is split (n), then the original problem can be (, split (n-3) 3) obtained by comparison max (2, split (n-2)) and max.

Guess you like

Origin www.cnblogs.com/Lebesgue/p/12080813.html