```
class Solution(object):
def mySqrt(self, x):
"""
:type x: int
:rtype: int
"""
import math
if x == 0:
return 0
a = 1.0
b = x
while abs(a-b)>1:
a = (a+b)/2
b = x/a
return int((a+b)/2)
```