Title:
Put a bunch of rows, each time you put one, there is a probability of pa to make the left side fall all over, and there is a probability of pb to make the right side fall all over
Q Under the optimal strategy, at least a few cards must be placed in order to place n cards
1<=n<=1000
answer:
It should still be a classic
The first is the expectation part
We split the sequence by enumerating the last step
It is easy to know that the middle point should be placed 1/(1-pa-pb) times
Then the number of times the left side is inverted is pa/(1-pa-pb) times
So the dp equation is very simple
dp[i]=min((dp[ls]*pa+dp[rs]*pb)/(1-pa-pb)+dp[ls]+dp[rs])
It is found that the naive is n^2
Property 1:
The unimodal function can then be divided into three points.
Property 2:
Concave function decision is monotonic
Be prepared to learn about proofs. .