题解 | #求小球落地5次后所经历的路程和第5次反弹的高度#
求小球落地5次后所经历的路程和第5次反弹的高度
https://www.nowcoder.com/practice/2f6f9339d151410583459847ecc98446
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.math.BigDecimal; import java.math.BigInteger; import java.text.DateFormat; import java.text.DecimalFormat; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; import java.util.*; import java.util.function.Function; import java.util.function.IntFunction; import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; import static java.util.Arrays.*; import static java.util.stream.Stream.*; public class Main { public static void main(String[] args) throws IOException { testTh(); } private static void testTh() throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); String str; while ((str = bf.readLine()) != null) { Double parseInt = Double.parseDouble(str); BigDecimal bigDecimal = new BigDecimal(parseInt + parseInt + parseInt / 2 + parseInt / 4 + parseInt / 8); BigDecimal high = new BigDecimal(parseInt / 32); DecimalFormat format = new DecimalFormat("#0.00000"); System.out.println(format.format(bigDecimal)); System.out.println(format.format(high)); } } }