找规律解题:代码来源
public int cuttingRope(int n) {
int res = 0;
if (n <= 3){
return n - 1;
}
int temp = n % 3;
if (temp == 0){
res = (int) Math.pow(3,n / 3);
} else if (temp == 1){
res = 4 * (int) Math.pow(3,(n / 3) - 1);
} else {
res = 2 * (int) Math.pow(3,n / 3);
}
return res;
}