SDUT 2402 水杯 Java

    xiaoxiao2021-03-25  105

    水杯

    Time Limit: 1000MS  Memory Limit: 65536KB Submit  Statistic

    Problem Description

    天气逐渐变热了,准备考研的高童鞋打算在夏天来临之前自己动手造一个水杯,以备口渴,你知道,高童鞋是个很挑剔而且古怪的的人,他每天喝的水是一定的,一滴也不多喝,一滴也不少喝,而且他用的杯子是个长方体!他认为这样才个性。 现在问题来了,你也知道,考研是多么的艰难,时间是多么的宝贵,钱是多么的不容易赚,所以高童鞋抠一点也正常了。作为他的好朋友,他想让你帮他做一个水杯,当然要花费最少。花费为1/m^2(每平方米一块钱)。

    Input

    第一行是T,代表有多少组测试数据。 第二行是M,代表水杯的体积。 T为整数,M为实数。

    Output

    最少的花费。(输出结果保留三位小数)

    Example Input

    1 3

    Example Output

    12.481

    import java.text.DecimalFormat; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { DecimalFormat th = new DecimalFormat("#0.000"); int T = sc.nextInt(); for (int i = 0; i < T; i++) { double n = sc.nextDouble(); double k = Math.pow(n, 2.0 / 3.0); System.out.println(th.format(k * 6)); } } } }

    转载请注明原文地址: https://ju.6miu.com/read-17520.html

    最新回复(0)