class Solution {
public:
int cuttingRope(int n) {
if(n <= 3) return n-1;
int cnt = n/3;
int t = n-cnt*3;
if(t == 0) return pow(3,cnt);
if(t == 1) return pow(3,cnt-1)*4;
return pow(3,cnt)*2;
}
};
剑指 Offer 14- I. 剪绳子.md
最新推荐文章于 2024-04-30 07:55:52 发布