class Solution {

public:

double pow(double x, int n) {

int flag = 0;

if(n==0)return 1;

if(x==1)return 1;

if(x==-1)return n%2==1? -1:1;

x<0?flag = 1:flag = 0;

if (flag == 1) {

x = -x;

}

if(n<0){

x = 1/x;

n = -n;

}

return flag&(n%2==1)? -exp(n*log(x)): exp(n*log(x));

}

};

Still with some problems with bad formatting..... Trying to do some improvement