#include #include #include #include #include #include #include int main() { int32_t r, c, p; std::cin >> r >> c >> p; // dp[1] std::vector dp(c + 1, 0.0); for (int32_t j = 2; j <= c; ++j) { dp[j] = p * 0.25 * (j - 1); } double scale = 0.5 / p; for (int32_t i = 2; i <= r; ++i) { std::vector ndp(c + 1); ndp[1] = (p / 4.0) * (i - 1); for (int32_t j = 2; j <= c; ++j) { double right = ndp[j - 1]; double down = dp[j]; double diff = std::abs(down - right); ndp[j] = (right + down - diff * diff * scale) * 0.5; } dp = std::move(ndp); } std::cout << std::setprecision(20) << std::fixed << dp.back() << '\n'; return 0; }