题解 | #求小球落地5次后所经历的路程和第5次反弹的高度#
求小球落地5次后所经历的路程和第5次反弹的高度
http://www.nowcoder.com/practice/2f6f9339d151410583459847ecc98446
用笔算最容易
import java.util.*; public class Main { public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); String num1 = String.format("%.6f",n*2.875); while(num1.endsWith("0")){ num1 = num1.substring(0,num1.length()-1); } String num2 = String.format("%.6f",n*0.03125); while(num2.endsWith("0")){ num2 = num2.substring(0,num2.length()-1); } System.out.println(num1); System.out.println(num2); } }