Implement pow(x, n).
class Solution {
public:
double pow(double x, int n) {
if(x==0) return 0;
if(n==0) return 1;
if(n==1) return x;
if(n<0) {
x=1/x;
n=abs(n);
}
if(n&1){
double t=pow(x,(n-1)/2);
return t*t*x;
}
else{
double t=pow(x,n/2);
return t*t;
}
}
};