题解 | #求小球落地5次后所经历的路程和第5次反弹的高度#
求小球落地5次后所经历的路程和第5次反弹的高度
https://www.nowcoder.com/practice/2f6f9339d151410583459847ecc98446
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.on('line', function (line) {
// 字符串转成数字
let s = line * 1
let h = s / 2
for(let i = 0; i < 4; i++){
// 所经过的路程
s += h*2
// 反弹高度
h /= 2
}
console.log(s)
console.log(h)
});


查看11道真题和解析