問題一覧 > 通常問題

No.959 tree and fire

レベル : / AI推定難易度 : 850 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 小数誤差許容問題 絶対誤差または相対誤差が $10^{-6}$ 以下。ただし、ジャッジ側の都合で500桁未満にしてください
タグ : (AC するまで非表示) / 解いたユーザー数 144
作問者 : homesentinel / テスター : tempura_pp
お気に入りにしたユーザー ProblemId : 3605 / 自分の提出
問題文最終更新日: 2019-12-18 17:22:04
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
Advent Calendar Contest 2019 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。