結果
| 問題 | 
                            No.959 tree and fire
                             | 
                    
| コンテスト | |
| ユーザー | 
                             cotton_fn_
                         | 
                    
| 提出日時 | 2020-02-02 14:34:32 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 8 ms / 2,000 ms | 
| コード長 | 930 bytes | 
| コンパイル時間 | 1,530 ms | 
| コンパイル使用メモリ | 116,520 KB | 
| 最終ジャッジ日時 | 2025-01-08 21:49:51 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 54 | 
ソースコード
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T> T iabs(const T& x) { return max(x, -x); }
int main() {
    i64 n, m;
    double p;
    cin >> n >> m >> p;
    if (n > m) swap(n, m);
    double ans;
    if (n == 1) {
        if (m == 1) {
            ans = p;
        } else {
            ans = (m - 2) * pow(p, 3) + 2 * pow(p, 2);
        }
    } else {
        ans = (n - 2) * (m - 2) * pow(p, 5)
            + (2 * (n - 2) + 2 * (m - 2)) * pow(p, 4)
            + 4 * pow(p, 3);
    }
    printf("%.10f\n", ans);
    return 0;
}
            
            
            
        
            
cotton_fn_