結果

問題 No.959 tree and fire
ユーザー tentententen
提出日時 2022-10-06 08:57:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 1,449 bytes
コンパイル時間 2,150 ms
コンパイル使用メモリ 73,696 KB
実行使用メモリ 49,824 KB
最終ジャッジ日時 2023-08-30 20:54:02
合計ジャッジ時間 6,630 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,500 KB
testcase_01 AC 43 ms
49,248 KB
testcase_02 AC 43 ms
49,592 KB
testcase_03 AC 43 ms
49,484 KB
testcase_04 AC 43 ms
49,612 KB
testcase_05 AC 43 ms
49,504 KB
testcase_06 AC 42 ms
49,620 KB
testcase_07 AC 45 ms
49,384 KB
testcase_08 AC 45 ms
49,608 KB
testcase_09 AC 43 ms
49,288 KB
testcase_10 AC 43 ms
49,692 KB
testcase_11 AC 44 ms
49,232 KB
testcase_12 AC 44 ms
49,536 KB
testcase_13 AC 44 ms
49,580 KB
testcase_14 AC 44 ms
49,340 KB
testcase_15 AC 43 ms
49,364 KB
testcase_16 AC 42 ms
49,536 KB
testcase_17 AC 43 ms
49,244 KB
testcase_18 AC 45 ms
49,696 KB
testcase_19 AC 43 ms
49,336 KB
testcase_20 AC 44 ms
49,548 KB
testcase_21 AC 44 ms
49,624 KB
testcase_22 AC 44 ms
49,696 KB
testcase_23 AC 43 ms
49,244 KB
testcase_24 AC 44 ms
49,388 KB
testcase_25 AC 44 ms
49,384 KB
testcase_26 AC 44 ms
49,620 KB
testcase_27 AC 43 ms
49,460 KB
testcase_28 AC 43 ms
49,384 KB
testcase_29 AC 43 ms
49,668 KB
testcase_30 AC 43 ms
49,256 KB
testcase_31 AC 43 ms
49,364 KB
testcase_32 AC 43 ms
49,480 KB
testcase_33 AC 43 ms
49,568 KB
testcase_34 AC 43 ms
49,304 KB
testcase_35 AC 44 ms
47,768 KB
testcase_36 AC 44 ms
49,684 KB
testcase_37 AC 43 ms
49,244 KB
testcase_38 AC 43 ms
49,352 KB
testcase_39 AC 43 ms
49,692 KB
testcase_40 AC 44 ms
49,344 KB
testcase_41 AC 43 ms
49,700 KB
testcase_42 AC 44 ms
49,624 KB
testcase_43 AC 44 ms
49,348 KB
testcase_44 AC 43 ms
49,596 KB
testcase_45 AC 43 ms
49,588 KB
testcase_46 AC 43 ms
49,396 KB
testcase_47 AC 43 ms
49,516 KB
testcase_48 AC 45 ms
49,264 KB
testcase_49 AC 44 ms
49,508 KB
testcase_50 AC 43 ms
49,280 KB
testcase_51 AC 44 ms
49,712 KB
testcase_52 AC 44 ms
49,476 KB
testcase_53 AC 44 ms
49,824 KB
testcase_54 AC 43 ms
49,476 KB
testcase_55 AC 43 ms
49,696 KB
testcase_56 AC 43 ms
49,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int m = sc.nextInt();
        double p = sc.nextDouble();
        double ans;
        if (n == 1 && m == 1) {
            ans = p;
        } else if (n == 1) {
            ans = Math.pow(p, 2) * 2 + Math.pow(p, 3) * (m - 2);
        } else if (m == 1) {
            ans = Math.pow(p, 2) * 2 + Math.pow(p, 3) * (n - 2);
        } else {
            ans = Math.pow(p, 3) * 4 + Math.pow(p, 4) * (m - 2 + n - 2) * 2 + Math.pow(p, 5) * ((long)n * m - n * 2 - m * 2 + 4);
        }
        System.out.println(ans);
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0