class Solution {
public static double myPow(double x, int n) {
if(n < 0){
x = 1/x;
n = -n;
}
return help(x,n);
}
public static double help(double x,int n){
if(n == 1){
return x;
}
if(n == 0){
return 1;
}
if(n % 2 == 0){
double temp=help(x,n/2);
return temp*temp;
}
else{
double temp=help(x,n/2);
return temp*temp*x;
}
}
}