Expected DP Summary

Source: Internet
Author: User

Although I know that after writing this summary maybe I still do not expect DP, but still want to take a tail, at least formally to come, and in case the writing is written on the thought of it.

Let's talk about how to ask for probabilities and expectations:

Probability: The probability of reaching the current state is equal to the probability of reaching the precursor state multiplied by the probability of reaching the current state, i.e. dp[now]=σ (Dp[pre]*p[pre][now]).

Expectation: The expectation of the current state equals the sum of all {successive states ' output values (expected) multiplied by their probability of reaching it}, i.e. e[now]=σ (P1*E[NXT1]+P2*E[NXT2]+P3*E[NXT3]+...+PK*E[NXTK]). (Can be understood as a weighted average) For example, a total of 10 cards, there are 7 can cause 1 of the proceeds, 3 can cause 1 of the proceeds, then the expected yield of the draw of the card is (7/10) *1+ (3/10) * (-1) = 0.4.

about what full expectation/full probability formula Ah what go to Baidu Bar, here no longer repeat.


The following combination of their own understanding and mathematics of a related summary, summed up the solution to the expected problem:

1. Able to simplify the formula O (1) It's no nonsense.

2. Can not write the general formula to consider the use of recursive solution

3. The expectation problem with decision-making and satisfying the optimal substructure is solved by dynamic programming

4. Some states can constitute the desired problem of the diagram, if only the linear equations can be listed, you may consider using Gaussian elimination (O (N^3)) to solve


The following review of the several OJ on the problem (in the school due to the Konjac konjac lazy sticky problem surface on it), here only with a question surface and a short problem, the following link is the specific problem of each topic (also not necessarily more detailed ...) ):

Bzoj 1419 Simple questions (scrolling array optimization)

Test instructions

There are r red cards and B-Black label on the table, randomly scrambled to the table, starting a one-card flop, turning the red card to get $1, Black Label $1. You can stop the flop at any time, and how much money you can get on average under the optimal strategy.

Exercises

Relatively simple DP, push-down can be (state definition is different).

Set F[i][j] indicates that I have used the red card, J Zhang Black Label the maximum expected income.

Transfer equation: F[i][j]=max (0.0,1.0*i/(i+j) * (f[i-1][j]+1) +1.0*j/(i+j) * (f[i][j-1]-1))

Boundary: F[i][0]=i

Explanation: http://blog.csdn.net/kgv093/article/details/78386235

Bzoj 4008 Overall design status

Test instructions

Given n skills, each skill is released with the probability of p[i in the input order and causes d[i] damage. Each game can only launch a skill, ask R wheel game total can cause damage expectations.

Exercises

Because it is difficult to design the status of a no-no-effect for each round alone (I did not want to come out anyway), consider each round (HO) together.

Set F[I][J] indicates the probability that the first skill has a J chance.

Explanation: http://blog.csdn.net/kgv093/article/details/78385788

Bzoj 3036 Template Questions

Test instructions

On a DAG, given the starting point, the probability of moving from one point to all of its child nodes is equal, asking the desired path to take the total length.

Exercises

Exactly each node corresponds to a state, according to the desired definition to push, perfect template problem.

Explanation: http://blog.csdn.net/kgv093/article/details/78385748

Bzoj 4318 indirectly represents expectations (record increments are added last)

Test instructions

Given a 0/1-string length of n, the probability of the first position of 1 is a[i], the final is divided into 01 strings in all together 1 of the length of the cubic and to obtain the desired points

Exercises

Maintains the contribution of the current bit to 1 relative to the previous bit of one-party increment f[i], squared increment g[i], cubic increment h[i]. (Concrete implementation to use the math formula (and the square/cubic))

Because the record is an increment, it will be added again at the end.

Explanation: http://blog.csdn.net/kgv093/article/details/78384485

POJ 3682 Auxiliary array processing (expect the desired number of times to be spent)

Test instructions

King Arthur throws a coin, the probability of a positive upward is p, the probability of the opposite facing up is 1-p, now it is necessary to throw K-times face up, and the first time to toss a coin to spend 2∗i−1. Q: The expected number of times and the expected cost of reaching the K-th face up.

Set G[i] indicates that there is already an I-second positive, to the number of times expected to K.

g[i]=g[i+1]+1/p

Set F[i] indicates that there has been an I-second positive, to the expected cost of the K-Times.

List the shift-move-item simplification, where no detailed procedure is required, forcing itself to be deduced again during review.

Boundary f[k]=0. It's starting to get a little tricky ...

Explanation: http://blog.csdn.net/kgv093/article/details/78383918

zoj 3640 Memory Search

Test instructions

A certain person, the initial combat value is F, facing N roads, each road has a difficulty degree ti, and exercise value CI. Every day he will wait for the probability to choose a road, if his combat value is greater than c[i], then he will spend t[i] days out, or he can not go out, but the combat value increased ti. T[i] and C[i] satisfy a given relationship (equivalent also given). Give N,f,c[i], ask to go out of the desired number of days.

Exercises

Set Dp[i] means ... I want to ... It is not difficult to tell what is one dimension now.

Explanation: http://blog.csdn.net/kgv093/article/details/78383893

bzoj 3450 Water Problem

Test instructions: Slightly

Exercises

A bit like Bzoj 4318 (cubic expectations) that problem, but this time the deposit is not an increment, this time 1~i expectations is what F[i] will save what.

Explanation: http://blog.csdn.net/kgv093/article/details/78365764

Bzoj 1426 Mathematical deduction and the perfect deduction of expectation

~ ~ ~ I think if the first time I do not look at the problem of their own launch, then you expect this section can graduate ~ ~ ~

Test instructions

There are n kinds of stamps, the first time I buy stamps to spend I yuan, every time you buy any one of the probability is 1/n, ask to buy the expected cost of n kinds of stamps.

Exercises

A bit like POJ 3682, but still more difficult to deduce the giant long code thief short. Ask for the desired number of times before the expected cost.

Explanation: http://blog.csdn.net/kgv093/article/details/78365130


There seems to be a lot of people recommend the topic of this Konjac Konjac has not done--bzoj 3143 Walk, need to use Gaussian elimination to solve, as soon as possible to complete the attached solution.

Finally, I enclose 3 water questions for the naive, just like me a week ago. Oier (detailed in the DP column of this KONJAC Konjac):

HDU 4405

HDU 3853

POJ 2096

That's all, if you get down to the expectation that DP will not be recognized.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.