快速幂板子
public class Solution {
public double Power(double base, int exponent) {
if(base == 0)return 0;
else if(exponent == 0)return 1;
if(exponent > 0)return quickPower(base, exponent);
else return 1.0 / quickPower(base, -exponent);
}
private double quickPower(double base, int exponent){
double res = 1;
while(exponent > 0){
if((exponent & 1) == 1)res *= base;
base = base * base;
exponent >>= 1;
}
return res;
}
}