自己写的。
求小球落地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.hasNextInt()) { double a = in.nextInt(); double sum = a; for (int i = 1; i < 5; i++) { a = a / 2; sum += 2 * a; } a = a / 2; System.out.println(String.format("%.6f", sum)); System.out.println(String.format("%.6f", a)); } } }