Sword Finger-Cut the Rope

public class Solution {     public int cutRope(int target) {         if(target <2)              return 0;         if(target == 2)             return 1;         if(target == 3)             return 2;         //Go as many functions as possible first Cut 3         int a = target/3;         //When the rope is only 4 left, it can no longer be cut         if(target-a*3 == 1)             a = a-1;         // Cut the remaining 4 to grow degree 2         int B = (a * target-3) / 2;         // find all the product 3 and the product obtained by multiplying the maximum product of 2         return (int) (Math.pow (3 , a) * Math.pow (2,b));     } }
















            

Guess you like

Origin blog.csdn.net/weixin_43562937/article/details/106950439