30,230
社区成员




今天参加第三次校内模拟赛,所以打卡打的比较晚~
题目:50. Pow(x, n) - 力扣(Leetcode)
class Solution:
def myPow(self, x: float, n: int) -> float:
if n < 0:
return self.myPow(1 / x, -n)
elif n == 0:
return 1
elif n == 1:
return x
if n % 2:
return x*self.myPow(x*x, n//2)
else:
return self.myPow(x*x, n//2)