結果

問題 No.959 tree and fire
ユーザー tentententen
提出日時 2020-12-01 08:43:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 2,468 ms
コンパイル使用メモリ 73,508 KB
実行使用メモリ 56,548 KB
最終ジャッジ日時 2023-10-11 03:24:23
合計ジャッジ時間 14,169 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
56,048 KB
testcase_01 AC 139 ms
55,736 KB
testcase_02 AC 137 ms
55,840 KB
testcase_03 AC 138 ms
55,732 KB
testcase_04 AC 139 ms
56,192 KB
testcase_05 AC 138 ms
55,992 KB
testcase_06 AC 137 ms
56,032 KB
testcase_07 AC 137 ms
56,400 KB
testcase_08 AC 138 ms
56,208 KB
testcase_09 AC 137 ms
56,028 KB
testcase_10 AC 137 ms
56,076 KB
testcase_11 AC 139 ms
56,064 KB
testcase_12 AC 136 ms
55,920 KB
testcase_13 AC 139 ms
56,188 KB
testcase_14 AC 139 ms
56,228 KB
testcase_15 AC 136 ms
54,332 KB
testcase_16 AC 135 ms
56,156 KB
testcase_17 AC 136 ms
54,784 KB
testcase_18 AC 134 ms
56,296 KB
testcase_19 AC 137 ms
56,292 KB
testcase_20 AC 140 ms
55,772 KB
testcase_21 AC 138 ms
56,260 KB
testcase_22 AC 138 ms
56,300 KB
testcase_23 AC 139 ms
56,136 KB
testcase_24 AC 139 ms
56,136 KB
testcase_25 AC 138 ms
55,996 KB
testcase_26 AC 138 ms
55,748 KB
testcase_27 AC 140 ms
56,284 KB
testcase_28 AC 138 ms
56,548 KB
testcase_29 AC 138 ms
56,040 KB
testcase_30 AC 139 ms
55,732 KB
testcase_31 AC 138 ms
56,260 KB
testcase_32 AC 138 ms
56,064 KB
testcase_33 AC 138 ms
56,176 KB
testcase_34 AC 138 ms
56,480 KB
testcase_35 AC 138 ms
56,064 KB
testcase_36 AC 138 ms
56,096 KB
testcase_37 AC 139 ms
55,992 KB
testcase_38 AC 140 ms
56,196 KB
testcase_39 AC 140 ms
56,496 KB
testcase_40 AC 139 ms
55,744 KB
testcase_41 AC 138 ms
56,188 KB
testcase_42 AC 139 ms
56,048 KB
testcase_43 AC 139 ms
55,928 KB
testcase_44 AC 136 ms
56,396 KB
testcase_45 AC 133 ms
56,264 KB
testcase_46 AC 135 ms
56,548 KB
testcase_47 AC 130 ms
55,592 KB
testcase_48 AC 136 ms
56,424 KB
testcase_49 AC 137 ms
55,944 KB
testcase_50 AC 135 ms
56,180 KB
testcase_51 AC 137 ms
56,212 KB
testcase_52 AC 140 ms
56,048 KB
testcase_53 AC 139 ms
56,076 KB
testcase_54 AC 138 ms
55,992 KB
testcase_55 AC 138 ms
56,152 KB
testcase_56 AC 140 ms
55,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        double rate = sc.nextDouble();
        if (h == 1 && w == 1) {
            System.out.println(rate);
        } else if (h == 1) {
            double ans = Math.pow(rate, 2) * 2 + Math.pow(rate, 3) * (w - 2);
            System.out.println(ans);
        } else if (w == 1) {
            double ans = Math.pow(rate, 2) * 2 + Math.pow(rate, 3) * (h - 2);
            System.out.println(ans);
        } else {
            double ans = Math.pow(rate, 3) * 4;
            ans += Math.pow(rate, 4) * (w - 2) * 2;
            ans += Math.pow(rate, 4) * (h - 2) * 2;
            ans += Math.pow(rate, 5) * (w - 2) * (h - 2);
            System.out.println(ans);
        }
    }
}
0