class Solution {
public int maxProductAfterCutting(int length)
{
if(length <= 3){
return 1*(length-1);
}
int result = 1;
if(length % 3 == 1){
result = 4;
length = length - 4;
}else if(length % 3 == 2){
result = 2;
length = length -2;
}
while(length != 0){
result *= 3;
length = length - 3;
}
return result;
}
}