1 public class Solution { 2 public int cutRope(int target) { 3 if (target == 2) return 1; 4 if (target == 3) return 2; 5 if (target == 4) return 4; 6 7 int []f = new int[target / 2 + 1]; 8 int ans = 1; 9 for (int i = 2; i <= target / 2; ++i) { 10 int temp = target % i; 11 int c = target / i; 12 int sum = 1; 13 for (int j = 0; j < i; ++j) { 14 if (j < temp) { 15 sum = sum * (c + 1); 16 } else { 17 sum = sum * c; 18 } 19 } 20 ans = Math.max(ans, sum); 21 22 } 23 24 return ans; 25 } 26 }
原文:https://www.cnblogs.com/hyxsolitude/p/12305318.html