Implement pow(x, n).
double myPow(double x, int n) { unsigned int m = n; bool flag = false; double ans = 1; if(n < 0) { flag = true; m = -n; } while(m) { if(m & 1) ans *= x; x = x * x; m = m>>1; } return flag ? 1/ans : ans; }
Implement pow(x, n).
double myPow(double x, int n) { unsigned int m = n; bool flag = false; double ans = 1; if(n < 0) { flag = true; m = -n; } while(m) { if(m & 1) ans *= x; x = x * x; m = m>>1; } return flag ? 1/ans : ans; }