class Solution:
    def pow(self, x, n):
        if n >= 2:
            v = self.pow(x, n // 2)
            return v * v if n % 2 == 0 else v * v * x
        elif n == 1:
            return x
        else:
            return 1

    def myPow(self, x: float, n: int) -> float:
        if n < 0:
            return 1 / self.pow(x, -n)
        else:
            return self.pow(x, n)
        pass


sol = Solution()
v = sol.myPow(2, 10)
v = sol.myPow(2, 6)
print(v)
v = sol.myPow(2, 3)
print(v)
v = sol.myPow(2, 2)
print(v)
v = sol.myPow(2, 1)
print(v)
v = sol.myPow(2, -2)
print(v)
