标签:tps leetcode ble while ref 链接 ret res ems
题目链接:https://leetcode-cn.com/problems/jian-sheng-zi-lcof/
class Solution {
public:
int cuttingRope(int n) {
if(n <= 3) return 1 * (n - 1);
int res = 1;
if(n % 3 == 1) res = 4, n -= 4;
else if(n % 3 == 2) res = 2, n -= 2;
while(n) res *= 3, n -= 3;
return res;
}
};
标签:tps leetcode ble while ref 链接 ret res ems
原文地址:https://www.cnblogs.com/Trevo/p/12739966.html