結果

問題 No.959 tree and fire
ユーザー fura
提出日時 2020-05-06 03:41:07
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 405 bytes
コンパイル時間 2,658 ms
コンパイル使用メモリ 191,352 KB
最終ジャッジ日時 2025-01-10 07:08:10
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 54
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	lint h,w;
	double p; cin>>h>>w>>p;

	if(h>w) swap(h,w);

	double ans=0;
	if(w==1){
		ans+=p;
	}
	else if(h==1){
		ans+=2*pow(p,2);
		ans+=(w-2)*pow(p,3);
	}
	else{
		ans+=4*pow(p,3);
		ans+=(2*h+2*w-8)*pow(p,4);
		ans+=(h-2)*(w-2)*pow(p,5);
	}
	printf("%.9f\n",ans);

	return 0;
}
0