链接:https://leetcode-cn.com/problems/jian-sheng-zi-ii-lcof/
代码:
class Solution { public: int cuttingRope(int n) { if(n < 4) return n - 1; long res = 1; while(n > 4) { res *= 3; res %= 1000000007; n -= 3; } return res * n % 1000000007; } };
链接:https://leetcode-cn.com/problems/jian-sheng-zi-ii-lcof/
class Solution { public: int cuttingRope(int n) { if(n < 4) return n - 1; long res = 1; while(n > 4) { res *= 3; res %= 1000000007; n -= 3; } return res * n % 1000000007; } };