double myPow(double x, int n) {
long long N = n;
if (N < 0) {
x = 1 / x;
N = -N;
}
double ans = 1;
double current = x;
for (long long i = N; i>0 ; i /= 2) {
if ((i % 2) == 1) {
ans = ans * current;
}
current = current * current;
}
return ans;
}
50. Pow(x, n)/C++
最新推荐文章于 2022-06-11 13:53:43 发布