[Algorithm] with the desired probability DP

Foreword

The main topic for the first two analyzes, Ke no time to skip.

preliminary

First give a simple, classic good question:
[Lightoj1038] Race to 1 Again
too lazy to write alone, Amway students blog about DennyQi: https://www.cnblogs.com/qixingzhi/p/9346307.html .
Obviously a lot of expectations and problems of their own state is related to, how to do it, do not stop searching yourself?
The above method obviously does not work, so we can simply look deformed.
Easy to list the equation:
\ [F [n-] = \ FRAC {\ sum_. 1} = {I m} ^ {F [fac_n ^ I]} + {m}. 1 \]
wherein \ (m \) represents a factor number, \ (fac_n ^ I \) represents \ (n-\) of \ (I \) factors.
Given the right to make erasing aftereffect, multiplying both sides while \ (m \) , transposition can.


Cite a slightly more complicated topics:
[zoj3329] the Person Game One
meaning of the questions briefly:
There are three dice, respectively, k1, k2, k3 faces.
0 record a fraction of the initial value, each dice, if three surfaces are a, b, c 0 is set to score, score of plus or dice and three.
When the end of the score greater than n. Demand expected number of steps of the game.
Set f [i] i has been obtained for the current time-expected number of steps end of the game.
For ease of presentation we may assume p [i] is the number of points invested in the probability i, special p [0] to return to zero probability.
Readily occur following recursion:
\ [F [I] = \ SUM (P [K] \ DP Times [K + I]) + DP [0] \ Times P [0] + 1'd \]
a glance Qing death, and into the ring, use Gaussian elimination no problem, the key is Gaussian elimination will TLE.
We found that we request something only f [0], so we dissociation constant, so that f [i] = A [i ] * f [0] + B [i]
then clearly we require f [0] to loved to becomes \ (\ FRAC {B [0] {}. 1-a [0]} \) .
Obviously we only need to calculate the recurrence A and B will be able to find the answer (nonsense).
So little modification A, to the following recursive formula B
\ [f [i] = \ sum (p [k] \ times A [i + k] \ times f [0] + p [k] \ times B [ i + k]) + f [ 0] * p [0] + 1 \]
\ [= (\ sum (p [k] \ times A [i + k]) + p [0]) f [0] + \ sum (p [k] \ times B [i + k]) + 1 \ ]
\ [A [I] = \ SUM (P [K] \ Times A [I + K]) + P [0], B [I] = \ SUM (P [K] \ Times B [I + K] ) +1 \]
then seek a, B becomes very simple QAQ.

Advanced

For unknown state to a ring and can not be completely transformed, only Gaussian elimination.
Gugu Gu.

skill

1, deformation of the recursive erasing aftereffect
2, but only part of a constant value may be isolated
3, using Gaussian elimination ring
Gugu Gu, (flag: expected finished up week).

Guess you like

Origin www.cnblogs.com/linzhengmin/p/11261550.html