#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using Int = long long int; int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10); Int N, M; double P; cin >> N >> M >> P; if (N == 1 && M == 1) { cout << P << endl; return 0; } if (N > M) swap(N, M); if (N == 1) { double ans = (M - 2) * pow(P, 3) + 2 * pow(P, 2); cout << ans << endl; return 0; } Int cnt_corner = 4; Int cnt_outer = max(0ll, N - 2) * 2 + max(0ll, M - 2) * 2; Int cnt_inner = N * M - cnt_corner - cnt_outer; double p_corner = pow(P, 3); double p_outer = pow(P, 4); double p_inner = pow(P, 5); double ans = cnt_corner * p_corner + cnt_outer * p_outer + cnt_inner * p_inner; cout << ans << endl; return 0; }