剑指 Offer 16. 数值的整数次方

tech2024-12-03  9

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)
最新回复(0)