题解 | #求小球落地5次后所经历的路程和第5次反弹的高度#
求小球落地5次后所经历的路程和第5次反弹的高度
https://www.nowcoder.com/practice/2f6f9339d151410583459847ecc98446
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNextDouble()) { double n = in.nextDouble(); double count = 0; double out = n; for (int i = 0; i < 5; i++) { count += out; out /= 2; if (i != 4) count += out; } System.out.print(count); System.out.println(); System.out.print(out); } } }