题解 | #求解立方根#
求解立方根
https://www.nowcoder.com/practice/caf35ae421194a1090c22fe223357dca
#没用二分法 不过也是自己写的 记录一下emm def xx(n, k=0, m=0): for i in range(k, k + 11): if i * i * i == n: return i / 10 ** m elif i * i * i > n: if m >= 3: #保留三位小数点 return (i - 1) / 10 ** m else: m += 1 return xx(n * 1000, (i - 1) * 10, m) while True: try: n = float(input()) if n > 0: print("{:.1f}".format(xx(n))) else: print("-{:.1f}".format(xx(abs(n)))) except: break