結果
問題 |
No.959 tree and fire
|
ユーザー |
![]() |
提出日時 | 2020-01-18 19:33:54 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 58 ms / 2,000 ms |
コード長 | 1,107 bytes |
コンパイル時間 | 2,128 ms |
コンパイル使用メモリ | 77,272 KB |
実行使用メモリ | 50,820 KB |
最終ジャッジ日時 | 2024-06-28 01:41:15 |
合計ジャッジ時間 | 6,677 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 54 |
ソースコード
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); double n = Integer.parseInt(line[0]); double 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); } }