結果

問題 No.959 tree and fire
ユーザー YamaKasa
提出日時 2019-12-24 21:16:36
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 580 bytes
コンパイル時間 1,588 ms
コンパイル使用メモリ 167,168 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-22 12:24:51
合計ジャッジ時間 3,093 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 54
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    double N, M, P;
    cin >> N >> M >> P;
    if (N > M) {
        ll t = M;
        M = N;
        N = t;
    }
    if (M == 1) {
        cout << P << "\n";
        return 0;
    }
    if (N == 1) {
        double ans = 2 * P * P;
        ans += pow(P, 3) * max(0.0, M - 2);
        printf("%10.8f\n", ans);
        return 0;
    }
    double ans = 4 * pow(P, 3) + (2 * (N - 2) + 2 * (M - 2)) * pow(P, 4) + (N * M - (2 * N + 2 * (M - 2))) * pow(P, 5);
    printf("%10.8f\n", ans);
    return 0;
}
0