Skip to content

Latest commit

 

History

History
20 lines (20 loc) · 330 Bytes

singleh4.md

File metadata and controls

20 lines (20 loc) · 330 Bytes

Integer Break

问题分析:

整数拆分,主要是观察规律。

编程实现:

class Solution {
public:
    int integerBreak(int n) {
        if(n==2||n==3) 
        return n-1;
        int res=1;
        while(n>4) 
        {
            res*=3;
            n-=3;
        }
        return res*n;
    }
};