class Solution {
public:
    double my_Pow(double x, long n)
    {
        if(n==0) return 1.0;
        if(n==1) return x;
        if(n<0) return my_Pow(1/x, -n);
        double result=my_Pow(x*x, n/2);
        if(n%2==1) result*=x;
        return result;
    }
    
    double myPow(double x, int n) {
        return my_Pow(x, n);
    }
};