思路:

1: 1

2: 1 * 1

3: 1 * 2

4: 2 * 2

5: 2 * 3

6: 3 * 3

7: 1 * 3 * 3

8: 2 * 3 * 3

可以发现,优先拆分3 > 2 > 1,先尽可能拆分成3,到4拆分成2、3以下返回n-1

class Solution:
    def cutRope(self , numbers: int) -> int:
        # write code here
        
        if numbers <= 3:
            return numbers - 1
        
        res = 1
        while numbers > 4:
            numbers -= 3
            res *= 3
        
        return numbers * res