题解 | #求解立方根#
求解立方根
https://www.nowcoder.com/practice/caf35ae421194a1090c22fe223357dca?tpId=37&tqId=21330&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fdifficulty%3D3%26page%3D1%26pageSize%3D50%26search%3D%26tpId%3D37%26type%3D37&difficulty=3&judgeStatus=undefined&tags=&title=
val = float(input()) # 这里的1.0设置还挺巧妙 l, r = min(-1.0, val), max(1.0, val) # 用区间大小进行判断 while r - l > 0.001: m = l + (r - l) / 2 if m ** 3 > val: r = m else: l = m print("{:.1f}".format(l))