結果
問題 | No.959 tree and fire |
ユーザー |
|
提出日時 | 2020-04-19 20:45:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 9 ms / 2,000 ms |
コード長 | 745 bytes |
コンパイル時間 | 1,761 ms |
コンパイル使用メモリ | 88,804 KB |
最終ジャッジ日時 | 2025-01-09 21:44:42 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 54 |
ソースコード
#include <iostream> #include <iomanip> #include <cmath> using ldouble = long double; using lint = long long; void solve() { lint n, m; ldouble p; std::cin >> n >> m >> p; if (n > m) std::swap(n, m); ldouble ans; if (n == 1) { if (m == 1) { ans = p; } else { ans = std::pow(p, 2) * 2 + std::pow(p, 3) * (m - 2); } } else { ans = std::pow(p, 3) * 4 + std::pow(p, 4) * ((n + m) * 2 - 8) + std::pow(p, 5) * (n - 2) * (m - 2); } std::cout << std::fixed << std::setprecision(10) << ans << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }