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