HJ38 求小球落地5次后所经历的路程和第5次反弹的高度 | 题解
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNext()) { double h = in.nextInt(); double s = h; for (int i = 0; i < 4; i++) { s += h; h /= 2.0; } h /= 2.0; System.out.println(s); System.out.println(h); } } }