题解 | #求解立方根#好难想啊
求解立方根
http://www.nowcoder.com/practice/caf35ae421194a1090c22fe223357dca
n = float(input())
if n == 0:
print(0.0)
elif n > 0:
sig = 1
else:
sig = -1
n = abs(n)
if n >= 1:
start = 1
end = n
else:
start = n
end = 1
mid = (start + end) / 2
while abs(mid ** 3 - n) > 0.001:
if mid ** 3 > n:
end = mid
else:
start = mid
mid = (start + end) / 2
print(round(sig * mid, 1))