```
class Solution(object):
def myPow(self, x, n):
"""
:type x: float
:type n: int
:rtype: float
"""
def pow(x, n):
if n == 1:
return x
tmp = pow(x, n//2)
return tmp*tmp if n%2 == 0 else tmp*tmp*x
if n == 0:
return 1
res = pow(x, abs(n))
return res if n>=0 else 1/res
```