結果

問題 No.1009 面積の求め方
ユーザー ntk3264ntk3264
提出日時 2020-04-03 02:12:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 738 bytes
コンパイル時間 2,117 ms
コンパイル使用メモリ 72,212 KB
実行使用メモリ 58,272 KB
最終ジャッジ日時 2023-09-11 02:41:52
合計ジャッジ時間 6,209 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
55,912 KB
testcase_01 AC 137 ms
56,020 KB
testcase_02 AC 138 ms
56,040 KB
testcase_03 AC 137 ms
55,984 KB
testcase_04 AC 136 ms
56,040 KB
testcase_05 AC 142 ms
56,212 KB
testcase_06 AC 139 ms
55,760 KB
testcase_07 AC 139 ms
55,932 KB
testcase_08 AC 137 ms
56,228 KB
testcase_09 AC 137 ms
56,120 KB
testcase_10 AC 139 ms
56,396 KB
testcase_11 AC 138 ms
58,272 KB
testcase_12 AC 139 ms
55,816 KB
testcase_13 AC 137 ms
55,932 KB
testcase_14 AC 139 ms
56,256 KB
testcase_15 AC 138 ms
56,188 KB
testcase_16 AC 138 ms
56,436 KB
testcase_17 AC 136 ms
55,712 KB
testcase_18 AC 145 ms
55,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        double a = sc.nextDouble();
        double b = sc.nextDouble();

        if (b < a) {
            double tmp = b;
            b = a;
            a = tmp;
        }

        double x3 = (double)1 / (double)3;
        double x2 = (a*(-1)+b*(-1)) / (double)2;
        double x1 = a * b;

        double ans = 0;

        ans = x3*(Math.pow(b, 3)-Math.pow(a, 3))+x2*(Math.pow(b, 2)-Math.pow(a, 2))+x1*(b-a);

        out.print(Math.abs(ans));
        out.flush();

    }

}
0