题解 | #星际穿越#
星际穿越
https://www.nowcoder.com/practice/53e4c208b8cf497086ecd65ef45349bb
一元二次方程
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
let h = await readline()
// 由题意得: x*x + x - h < 0
let x1,x2 ,delta;
delta = 1+ 4 * h;
x1 = (-1 - Math.sqrt(delta))/2
x2 = (-1 + Math.sqrt(delta))/2
console.log(Math.floor(x2))
}()
查看17道真题和解析
阿里巴巴公司氛围 661人发布