分治策略解决幂乘问题

float fast_pow ( float x, float y ) {
 
    if ( y == 1 )
        return x;
 
    else if ( (int)y % 2 == 0 )
        return fast_pow(x,y/2)*fast_pow(x,y/2);
 
    else
        return fast_pow(x,(y-1)/2)*fast_pow(x,(y-1)/2)*x;
}
原文地址:https://www.cnblogs.com/Nicholastwo/p/9368076.html