class Solution {
public int maxProductAfterCutting(int length)
{
if(length <= 3) {
return length - 1;
}
int result = 1;
if(length % 3 ==1) {
result =4;
length -= 4;
}
if(length % 3 == 2) {
result = 2;
length -= 2;
}
while(length > 0) {
length -= 3;
result = 3;
}
return result;
}
}
1.拆分出得数一定小于5,因为x>=5 3(x-3) = 3x-9>x,只要拆分出的x>=5,就可以拆分为3和x-3
2.遇到4就不行,必须拆为2*2