```
public class Solution {
public double MyPow(double x, int n) {
long longN=(long)Math.Abs((long)n);
double i = MyPow(x,longN);
if(n<0)
return ((double)1)/i;
else
return i;
}
private double MyPow(double x, long longN)
{
if(longN==0)
return (double)1;
if(longN==1)
return x;
if((longN&1)==0)
return MyPow(x*x, longN/2);
else
return MyPow(x*x, longN/2)*x;
}
}
```