11.4 PM Coins game

The meaning of problems

You flip a coin. Which is thrown into the front of the probability \ (the p-\) , a request continuously for the first time \ (k \) times the expected number of positive steps


solution

Desired first contact DP

According subject to set state, set \ (f_i \) is continuous for the first time \ (i \) times the expected number of positive steps

Consider the impact of a coin toss to bring: throw a positive, can make continuous \ (i-1 \) extension of the continuous \ (i \) times; once thrown back, you can make continuous \ (i-1 \) times to empty is \ (0 \) times, still need to throw \ (F_i \) times
\ [f_i = p \ times ( f_ {i-1} +1) + (1-p) \ times (f_ {i-1} + 1 + f_i) \]
this will be a simplified equation can be used to optimize the geometric series summation formula, so they can be \ (O (\ log N) \) solved


Code

Nothing to put

Guess you like

Origin www.cnblogs.com/VeniVidiVici/p/11801062.html