My solution is:

```
class Solution:
# @param x, a float
# @param n, a integer
# @return a float
def pow(self, x, n):
p, newp, y = 0, 1, abs(x)
if n < 0 :
y, n = 1.0/y, -n
while p != newp:
p = newp
if n == 0:
break
else:
newp, n = p * y, n - 1
return -p if x < 0 and n % 2 else p
```

It gets Time Limit Exceed at -1.00000, -2147483648.

But, I can get the result on my own desktop.

Can anyone explain what was wrong with my code?

Actually, it needs only one iteration to get the answer for this input ...