/* -*- coding: utf-8 -*- * * 959.cc: No.959 tree and fire - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ /* typedef */ typedef long long ll; /* global variables */ ll nbrs[5]; /* subroutines */ /* main */ int main() { int n, m; double p; scanf("%d%d%lf", &n, &m, &p); if (n > m) swap(n, m); if (n == 1) { if (m == 1) nbrs[0] = 1; else { nbrs[1] = 2; nbrs[2] = m - 2; } } else { nbrs[2] = 4; nbrs[3] = (ll)((n - 2) + (m - 2)) * 2; nbrs[4] = (ll)(n - 2) * (m - 2); } double sum = 0.0, ep = p; for (int i = 0; i <= 4; i++, ep *= p) sum += ep * nbrs[i]; printf("%.10lf\n", sum); return 0; }