Skip to main content

🟡 剑指 Offer 14- II. 剪绳子 II

LeetCode 提示

题目难度 中等

原题链接 🔗 leetcode

题解 1.py#

class Solution:    def cuttingRope(self, n: int) -> int:        maxx = 1        for nn in range(2, n):            ps = n//nn            left = n%nn            maxx = max(maxx, pow((ps+1), left) * pow(ps, (nn-left)))        return maxx % 1000000007