题解 | #求小球落地5次后所经历的路程和第5次反弹的高度#
求小球落地5次后所经历的路程和第5次反弹的高度
https://www.nowcoder.com/practice/2f6f9339d151410583459847ecc98446
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()){
let h = parseInt(line);
let distants = h;
let rebounceH = h;
for(let i = 0; i < 5; i++){
distants += h * Math.pow(0.5, i);
rebounceH *= 0.5;
}
console.log(distants - rebounceH*2);
console.log(rebounceH);
}
}()
