class Solution:
def myPow(self
, x
: float, n
: int) -> float:
if n
==0:
return 1
if n
<0:
return self
.myPow
(1/x
,-n
)
if n
%2==1:
return x
*self
.myPow
(x
*x
,n
//2)
return self
.myPow
(x
* x
, n
// 2)
转载请注明原文地址:https://tech.qufami.com/read-19437.html