No.959 tree and fire
タグ : / 解いたユーザー数 144
作問者 :
homesentinel
/ テスター :
tempura_pp
Problem Statement
There is an $N \times M$ grid of cells.
Initially, each cell contains a tree with probability $P$, and a cell without a tree contains fire.
Any tree in a 4-neighbor of a fire (a cell sharing an edge with the fire) disappears.
Find the expected number of trees that do not disappear.
Your answer is considered correct if its relative error or absolute error is at most $10 ^ {-6}$.
Input
$N\ M$ $P$
$1 \le N, M \le 10^9$
$0 \le P \le 1 $
$N, M$ are integers
$P$ is a real number with at most 7 digits after the decimal point
Output
Output the expected number of trees that do not disappear.
Sample
Sample 1
Input
1 2 0.5
Output
0.5000000000
The probability that the number of trees that do not disappear is 0 is 0.75
The probability that the number of trees that do not disappear is 2 is 0.25
Therefore, the expected value is 0.5.
Sample 2
Input
2 2 0.25
Output
0.0625000000
Sample 3
Input
1333 79 0.63
Output
10615.7879680041
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。