Integer Break

来源:互联网 发布:软件项目质量保证 编辑:程序博客网 时间:2024/05/19 17:07

c++

class Solution {public:    int integerBreak(int n) {        if (n < 2) return 0;        if (n == 2) return 1;        if (n == 3) return 2;        int res = 1;        while (n > 4) {            res *= 3;            n -= 3;        }        res *= n;        return res;    }};
0 0
原创粉丝点击