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
;
}
转载请注明原文地址: https://win8.8miu.com/read-12695.html