結果
問題 |
No.959 tree and fire
|
ユーザー |
|
提出日時 | 2022-10-03 23:50:00 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 796 bytes |
コンパイル時間 | 2,103 ms |
コンパイル使用メモリ | 193,912 KB |
最終ジャッジ日時 | 2025-02-07 21:03:34 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 WA * 19 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); using ld = long double; int N,M; ld P; cin >> N >> M >> P; if(N > M) swap(N, M); ld ans = 0; if(M == 1) { ans += P; } else if(N == 1) { // k = 1 : 2マス // k = 2 : M-2マス ans += 2.0 * powl(P, 1 + 1); ans += (M - 2) * powl(P, 2 + 1); } else { // k = 2 : 4マス // k = 3 : 2(N-2+M-2)マス // k = 4 : (N-1)(M-1)マス ans += 4.0 * powl(P, 2 + 1); ans += 2.0 * (N - 2 + M - 2) * powl(P, 3 + 1); ans += (N - 2) * (M - 2) * powl(P, 4 + 1); } cout << fixed << setprecision(20) << ans << endl; }