题解 | #求解立方根暴力遍历!!还有谁???
求解立方根
https://www.nowcoder.com/practice/caf35ae421194a1090c22fe223357dca?tpId=37&tqId=21330&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D3%26tpId%3D37%26type%3D37&difficulty=undefined&judgeStatus=undefined&tags=&title=
num_float=float(input()) num_1f=0.1 num_2f=-0.1 error=0 while 1: if num_float==0.0: print('0.0') elif num_float>0: error=num_float-num_1f**3 if num_float-num_1f**3<0: if num_1f**3-num_float > num_float-(num_1f-0.1)**3: num_1f=num_1f-0.1 print(round(num_1f,1)) break else: num_1f+=0.1 elif num_float<0: if num_float-num_2f**3>0: if num_float-num_2f**3 > (num_2f+0.1)**3-num_float: num_2f=num_2f+0.1 print(round(num_2f,1)) break else: num_2f-=0.1