题解 | #求解立方根#
求解立方根
https://www.nowcoder.com/practice/caf35ae421194a1090c22fe223357dca
const rl = require("readline").createInterface({ input: process.stdin }); var iter = rl[Symbol.asyncIterator](); const readline = async () => (await iter.next()).value; void async function () { // Write your code here while(line = await readline()){ const num = Number(line) const x = 0.0001; let low = Math.min(-1,num) let high = Math.max(1,num) let center = (low+high)/2 while(Math.abs(center**3 - num) >= x){ if(center**3<num){ low = center }else{ high = center } center = (low+high)/2 } console.log(center.toFixed(1)) } }()