题目:求x的平方根
思路:牛顿法,https://en.wikipedia.org/wiki/Newton%27s_method
class Solution(object):
def mySqrt(self, x):
"""
:type x: int
:rtype: int
"""
if x==0:return 0
last=0.0;res=1.0
while last!=res:
last=res
res=(res+x/res)/2
return int(res)