題解 | #求解立方根#
求解立方根
http://www.fangfengwang8.cn/practice/caf35ae421194a1090c22fe223357dca
# 小白計(jì)算法
i=float(input())
n=-1*i if i<0 else i
a,b,c=0,0,0
while (a+1)**3<=int(n):
a+=1
while (a+(0.1*(b+1)))**3<=float(n):
b+=1
while (a+0.1*b+0.01*(c+1))**3<=float(n):
c+=1
print((round(-1*(a+0.1*b),1) if c<5 else round(-1*(a+0.1*(b+1)),1)) if i<0 else (round(a+0.1*b,1) if c<5 else round(a+0.1*(b+1),1)))
i=float(input())
n=-1*i if i<0 else i
a,b,c=0,0,0
while (a+1)**3<=int(n):
a+=1
while (a+(0.1*(b+1)))**3<=float(n):
b+=1
while (a+0.1*b+0.01*(c+1))**3<=float(n):
c+=1
print((round(-1*(a+0.1*b),1) if c<5 else round(-1*(a+0.1*(b+1)),1)) if i<0 else (round(a+0.1*b,1) if c<5 else round(a+0.1*(b+1),1)))