結果

問題 No.959 tree and fire
ユーザー hipopohipopo
提出日時 2019-12-25 23:25:45
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 546 bytes
コンパイル時間 2,229 ms
コンパイル使用メモリ 191,948 KB
最終ジャッジ日時 2025-01-08 15:12:29
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 52 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, m;
    double p;
    cin >> n >> m >> p;
    if (n > m) swap(n, m);

    if (n == 1) {
        if (m == 1) printf("%.10f\n", p);
        else {
            double ans = pow(p, 2) * 2 + pow(p, 3) * (m - 2);
            printf("%.10f\n", ans);
        }
        return 0;
    }

    double s1 = pow(p, 3) * 4;
    double s2 = pow(p, 4) * (max(0, n - 2) * 2 + max(0, m - 2) * 2);
    double s3 = pow(p, 5) * max(0, n - 2) * max(0, m - 2);

    printf("%.10f\n", s1 + s2 + s3);
}
0