题解 | #剪绳子#
剪绳子
http://www.nowcoder.com/practice/57d85990ba5b440ab888fc72b0751bf8
想考我数学,不存在的。DP直接怼
public class Solution {
public int cutRope(int target) {
int[] dp = new int[target + 1];
for(int i = 0; i <= target; i++) {
dp[i] = i;
}
for(int i = 0; i <= target; i++) {
for(int j = 0; j < i; j++) {
dp[i] = Math.max(dp[j] * dp[i-j], dp[i]);
}
}
return dp[target];
}
}