题解 | #求解立方根#
求解立方根
http://www.nowcoder.com/practice/caf35ae421194a1090c22fe223357dca
while True:
try:
x = float(input())
if x==0:
print(0)
break
if x>0:
sig =1
else:
sig =-1
x = abs(x)
if x>1:
low,high = 1,x
else:
low,high =x,1
while (low <= high):
mid = (low+high)/2
if abs(mid**3 -x)<=0.01:
print(round(sig*mid,1))
break
elif mid**3 -x <0:
low = mid
elif mid**3 -x >0:
high = mid
except:
break