七星剑
$Description$
$Solution$
设 $f_i$ 表示镶 $i$ 颗魔法石的期望。
$$
f_i = C_j + f_{i - 1} + (f_i - f_{i - 1 - Lose[i][j]}) \times (1 - Prod_{i, j})
$$
$$
f_i \times Prod_{i, j} = C_j + f_{i - 1} - (1 - Prod_{i, j}) \times f_{i - 1 - Lose[i][j]}
$$
$$
f_i = \frac{C_j + f_{i - 1} - f_{i - 1 - Lose[i][j]} \times (1 - Prod_{i, j})}{Prod_{i, j}}
$$
$Code:$
1 |
|