結果

問題 No.959 tree and fire
ユーザー htensai
提出日時 2020-01-18 19:31:22
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,101 bytes
コンパイル時間 2,072 ms
コンパイル使用メモリ 77,388 KB
実行使用メモリ 50,784 KB
最終ジャッジ日時 2024-06-28 01:36:30
合計ジャッジ時間 6,999 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 52 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ", 3);
        int n = Integer.parseInt(line[0]);
        int m = Integer.parseInt(line[1]);
        double p = Double.parseDouble(br.readLine());
        if (n == 1 && m == 1) {
            System.out.println(p);
            return;
        } else if (n == 1) {
            double ans = 0;
            ans += Math.pow(p, 2) * 2;
            ans += Math.pow(p, 3) * (m - 2);
            System.out.println(ans);
            return;
        } else if (m == 1) {
            double ans = 0;
            ans += Math.pow(p, 2) * 2;
            ans += Math.pow(p, 3) * (n - 2);
            System.out.println(ans);
            return;
        }
        double ans = 0;
        ans += Math.pow(p, 3) * 4;
        ans += Math.pow(p, 4) * ((n - 2) * 2 + (m - 2) * 2);
        ans += Math.pow(p, 5) * (n - 2) * (m - 2);
        System.out.println(ans);
    }
}
0