結果

問題 No.959 tree and fire
ユーザー tko919
提出日時 2019-12-22 09:38:07
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 999 bytes
コンパイル時間 1,505 ms
コンパイル使用メモリ 168,468 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-13 22:32:07
合計ジャッジ時間 3,016 ms
ジャッジサーバーID
(参考情報)
judge5 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other AC * 8 WA * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
string to_str(ll x){string res; while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return res;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end



int main(){
    int h,w; scanf("%d%d",&h,&w);
    if(h>w)swap(h,w);
    double p; scanf("%Lf",&p);
    double ans=0;
    if(h==1){
        if(w==1)ans=p;
        else{
            ans+=2*pow(p,2);
            ans+=(w-2)*pow(p,3);
        }
    }
    else{
        ans+=(h-2)*(w-2)*pow(p,5);
        ans+=2*(h-2+w-2)*pow(p,4);
        ans+=4*pow(p,3);
    }
    printf("%.12f\n",ans);
    return 0;
}
0