class Solution(object):
def mySqrt(self, x):
"""
:type x: int
:rtype: int
"""
if x < 2:
return x
new_num = x // 2
while True:
if new_num ** 2 == x:
return new_num
if new_num ** 2 < x:
break
new_num = new_num // 2
# print("ohohooo", new_num)
# return 1
for i in range(new_num, new_num*2+1):
# print("hahah", i)
if i ** 2 <= x and x < (i+1) ** 2:
return i