結果

問題 No.959 tree and fire
ユーザー tenten
提出日時 2020-12-01 08:43:34
言語 Java
(openjdk 23)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 2,196 ms
コンパイル使用メモリ 77,192 KB
実行使用メモリ 54,712 KB
最終ジャッジ日時 2024-09-13 02:51:01
合計ジャッジ時間 12,185 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 54
権限があれば一括ダウンロードができます

ソースコード

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