結果
| 問題 |
No.959 tree and fire
|
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2022-10-06 08:57:20 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 54 ms / 2,000 ms |
| コード長 | 1,449 bytes |
| コンパイル時間 | 2,783 ms |
| コンパイル使用メモリ | 79,864 KB |
| 実行使用メモリ | 49,544 KB |
| 最終ジャッジ日時 | 2025-01-02 17:34:37 |
| 合計ジャッジ時間 | 7,862 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 54 |
ソースコード
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();
}
}
tenten