class Solution {
public:
double myPow(double x, int n) {
double sum=1.00000;
if(n==0)return 1;
if(n==1)return x;
for(int i=n;i!=0;i=i/2){
if(i%2!=0){sum=sum*x;}
x=x*x;
}
return n>0?sum:1/sum;
}
};