新版剑指offer14 剪绳子

int maxProduct(int length){
    if(length < 2)
        return 0;
    if(length = 2)
        return 1;
    if(length = 3)
        return 2;
    int numof3 = length/3;
    if(length - numof3*3 == 1)
        numof3 -= 1;
    int numof2 = (length - numof3*3)/2;
    return (int)(pow(3,numof3))*(int)(pow(2,numof2)); 
}

猜你喜欢

转载自www.cnblogs.com/ymjyqsx/p/9644925.html