mycode  time limited

例如 x=0.00001 n=2147483647

 

参考:

class Solution(object):
    def myPow(self, x, n):
        """
        :type x: float
        :type n: int
        :rtype: float
        """
        if n == 0 : return 1
        if n < 0 : return 1.0/self.myPow(x,-n)
        if n%2 == 1 : 
            print(x,n)
            return x*self.myPow(x*x,n//2)
        else: 
            print(x,n)
            return self.myPow(x*x,n//2)