题解 | #求小球落地5次后所经历的路程和第5次反弹的高度#
求小球落地5次后所经历的路程和第5次反弹的高度
http://www.nowcoder.com/practice/2f6f9339d151410583459847ecc98446
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
double n = Double.valueOf(scan.nextLine().trim());
double total = 0.0;
for (int i = 1; i <= 5; i++) {
total += n;
n /= 2;
total += n;
}
System.out.println(total - n);
System.out.println(n);
}
}