题解 | #求小球落地5次后所经历的路程和第5次反弹的高度#
求小球落地5次后所经历的路程和第5次反弹的高度
https://www.nowcoder.com/practice/2f6f9339d151410583459847ecc98446
import java.util.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNext()) { // 注意 while 处理多个 case
double a = in.nextDouble();
double res = a*23/8;
System.out.println(a*23/8);
System.out.println(a/32);
}
}
}
这压根就是一道数学题
归纳规律总结公式得:
sumH = h + 2(h/2+h/2^2+h/2^3+h/2^4)
通分得:
sumH = h + 2(8h/16 + 4h/16 + 2h/16 + h/16)
整理得 sumH=23h/8;
h5 = h/2^5 = h/32;


查看9道真题和解析