Python实现 pow(x, n) ,即计算 x 的整数 n 次幂函数(即,xn )。
def myPow(self, x: float, n: int) -> float:
if x==0:return 0
res=1
if n<0:x,n=1/x,-n
while n:
if n&1:res*=x
x*=x
n>>=1
return res