public class Solution {
public double Power(double base, int exponent) {
if(exponent > 1 || exponent < -1) {
int a = (int)(exponent / 2);
double res = Power(base, a);
return res * res * Power(base, exponent - a * 2);
} else if(exponent == 0) {
return 1.0;
} else if(exponent == 1) {
return base;
} else {
return 1.0 / base;
}
}
}