思路 class Solution { public: int cuttingRope(int n) { if (n<4) return n-1;// n=2,返回1, n=3, 返回2 int k = n / 3; int res; if(n%3==1){ res = pow(3, k-1) * 2 * 2; }else if (n%3==2){ res = pow(3, k) * 2; }else{ res = pow(3,k); } return res; } };