結果
| 問題 | No.959 tree and fire |
| コンテスト | |
| ユーザー |
mighty-isuka
|
| 提出日時 | 2020-01-24 15:53:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 931 bytes |
| 記録 | |
| コンパイル時間 | 1,692 ms |
| コンパイル使用メモリ | 173,144 KB |
| 実行使用メモリ | 814,952 KB |
| 最終ジャッジ日時 | 2024-09-14 03:42:28 |
| 合計ジャッジ時間 | 6,066 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 5 WA * 6 RE * 3 MLE * 1 -- * 39 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
long N,M;
cin>>N>>M;
cout <<fixed<< setprecision(10) ;
double p;
cin>>p;
vector<vector<int>>map(N,vector<int>(M,1));
for(int i=0;i<N;i++){
for(int j=0;j<M;j++){
if(0<i&&i<N-1)map[i][j]+=2;
else if(i==0||i==N-1)map[i][j]+=1;
if(0<j&&j<M-1)map[i][j]+=2;
else if(j==0||j==M-1)map[i][j]+=1;
}
}
double t=0;
if(N>2&&M>2){
for(int i=0;i<N;i++){
for(int j=0;j<M;j++){
double lp=1;
lp*=pow(p,map[i][j]);
t+=lp;
}
}
cout<<t<<endl;
}else if(N==1&&M==1) cout<<p<<endl;
else{
int m=max(N,M);
for(int i=0;i<m;i++){
double pl=p;
if(i==0||i==m-1)pl=pl*p;
else pl=pl*p*p;
t+=pl;
}
cout<<t<<endl;
}
}
mighty-isuka