实现 pow(x, n) ,即计算 x 的 n 次幂函数。
示例 1:
输入: 2.00000, 10 输出: 1024.00000
class Solution: def myPow(self, x, n): """ :type x: float :type n: int :rtype: float """ if n < 0: return self.myPow(1/x,-n) if n == 0: return 1 if n == 2: return x*x return self.myPow(self.myPow(x,n/2),2) if not n%2 else x * self.myPow(self.myPow(x,n//2),2)