代码
class Solution {
public:
#define LL long long
double myPow(double x, int n) {
double ans = 1, p = x;
LL t = abs((LL)(n));
for (; t; t >>= 1) {
if (t & 1) {
ans = ans * p;
}
p = p * p;
}
return n > 0 ? ans : 1 / ans;
}
};