Probability:
POJ 2151
There is a T-team, M-problem, give each team to make each problem probability. Find out that each team has at least one problem and the championship team has at least the probability of making n questions.
Each team has at least one problem in the opposite incident is that each team to make at most 0 questions. Therefore, each pair must be asked to make 0 probabilities.
The odds of a champion team making at least n questions is that all teams make the most of the n-1, so it is necessary to keep track of the probability of each team making the most X-channel.
The ability to set S[I][J] indicates the probability that I will make a J-question. It is also necessary to use dp[i][j][k] to indicate the probability that team I will make a K-question in the first J-question.
It's easy to find the opposite.
id=3744 ">poj 3744
There are N Thunder. A person's starting position in 1, each step of the probability of P, walking two steps of the probability is 1-p, give the position of N lei. Ask the probability of the final successful exit from the minefield.
Successful out of the minefield indicates that every minefield has not been stepped on. Then only the demand for each mined area is not stepping on the probability of multiplying. The probability of not stepping on the No. I minefield is 1-the probability of stepping on the I-mined area.
Able to segment mined area 1~num[1],num[1]+1~num[2] ... Each paragraph has only one Ray Num[i], each section is the same as the first paragraph, dp[i] represents the probability at I point. Then dp[i] = dp[i-1]*p + dp[i-2]* (1-p). Note here that I is the starting position of each paragraph, the first position of each paragraph must go, DP "1" = 1.
CF D
is also a probability, just need to reverse push, accurately find out the state of the transfer.
With I only the white mouse J only black rat in the state of the Princess winning probability is dp[i][j]. This state can be obtained in three states:
For the first time, the Princess won a white mouse, the probability of i/(I+J).
Princess did not take the white mouse, take black rat probability is j/(i+j), if the princess to win, the next dragon must take black rat. The probability is (j-1)/(i+j-1), the same time run off is the black rat, the probability is (j-2)/(i+j-2), state transfer to dp[i][j-3];
The princess did not take the white mouse. The probability of taking black rat is j/(i+j). If the princess wants to win, the next dragon must take black rat, the probability is (j-1)/(i+j-1). At the same time, the white rat ran away. The probability is i/(i+j-2), the state shifts to dp[i-1][j-2];
Expect:
HDU 4586
A DICE has n faces, each face has a corresponding amount of money, when thrown on the M-plane will add an opportunity.
Ask for the last hope of getting money.
This is a complicated question to think about. Do not know how to determine the final state.
In fact, it is only necessary to consider the case of throwing once, the expectation of throwing once is P = sum/n, but if thrown to one of the M faces, there will be another chance, the second throw of the situation and the first time is completely the same. Then the second expectation of throwing is m/n*p, and so on, the expectation of throwing N times is (m/n) ^ (N-1) *p.
The sum of these expectations is the answer, to see that N is geometric series, the ultimate summation.
POJ No. 2096-stage entry question
The bug of the program has n subsets, s of the kind. The probability of each bug belonging to each subset is 1/n. Each bug belongs to the probability of each species as 1/s, asking every subset and each category has a bug expectation.
By listing the state transition equations, the equation is conquered.
HDU 3853
The desire to spend power from "r,c" to "zero" is 2 of power consumed per step, given from [I,j] to [i,j]. [I,j+1]. [I+1] [j] Probability.
is also a simple expectation, reverse push can be. Pay special attention to the probability that the original point does not move at 1 o'clock, simply cannot go to "r,c".
HDU 4405
There is a n+1 point. 0~n, someone standing at x now, if X has flight lines, he can fly to the corresponding point without throwing the dice, or forward the roll of the dice on the number.
Ask him the average number of times the dice need to be thrown from 0 o'clock to n points.
Determine the end state Dp[n] = 0, then reverse push, together with two cases, roll the dice and do not roll the dice.
pid=4336 ">hdu 4336
There are n cards, and each bag has a maximum of one card, giving the probability of each card in a bag of snacks, asking how many bags of snacks on average can collect all the cards.
N <= 20, state compression. Determine the end state dp[(1<<n)-1] = 0. Pay special attention to p1+p2+...+pn<=1, stating that there will be no card in a bag of snacks.
The state compresses it a bit. A common 1<<n-1 state, set Dp[sta] indicates the current state to the target state of the average number of snacks bought, the known end state dp[1<<n-1] = 0,dp[sta] can be obtained by the State:
There is no card in this bag of snacks, the probability is P (the probability of not having a card). State transfer to STA;
This bag of snacks has a card J, but he already has such a card, the probability is a[j]. The state is transferred to the STA.
This bag of snacks has a card J, and there was no, the probability is a[j], the state transferred to STA | (1 << j)
Zoj 3640
Similar types of questions. One of the vampires was trapped and there were n ways to escape. Each road has a difficulty c[], his initial combat effectiveness is f. For route I, F > c[i] He can go out t[i days. Otherwise, he will stay one day, the same time combat effectiveness add c[i] and then choose a road to go out, he walked the probability of each road is the same.
Ask him about the number of days he escaped.
Set Dp[i] indicates the expected value of escaping at the time of fighting, then the state equation can be introduced Dp[i] = 1/n * T[j] (C[j] > I), dp[i] = 1/n * (1+dp[I+c[j]]) (C[j] <= i). the easy-to-ignore point is the determination of the final state. It should be max*2. Because I+c[j] is very likely to be larger than Max.
problemid=3754 ">zoj 3329
Very good topic.
There are 3 dice, each of which has a a,b,c face. Each face is equal to the probability.
The current state I, when three faces are thrown k1,k2,k3 back to the state 0, otherwise reached the state I+k1+k2+k3, asked to throw out the >=n the number of times the expectation. The state transition equation is very good to push. Dp[i]=p0*dp[0]+pk*dp[i+k], a detailed analysis of this equation differs from the equation above, it contains the required amount of dp[0], there is a ring.
found that each equation can be expressed by dp[0], then set Dp[i]=a[i]*dp[0]+b[i], with the above can get a[i] and B[i] recursion. Then a[0] and b[0] will be able to find out dp[0].
SGU 495
There are n prizes placed in n boxes. There are m children randomly to choose a box, if there is a prize to take away. Put the empty box back, whether it's a prize or not.
Ask for the last prize to be expected.
Taking n prizes as the object of consideration, m personal choice is independent of each other. Then for a prize the selected p = 1-((n-1)/n) ^m.
Then the expectation that the prize is chosen is p*1, then the total winning expectation is p*n.
pid=4652 ">hdu 4652
Very good topic. throw a dice and have m faces. Ask for a continuous occurrence of n the same face and a continuous occurrence of n 22 different faces of the expectation.
DP "I" means that I have the same/22 different faces.
End State Dp[n] = 0. For occurrences of n consecutive same polygon dp[i] = 1/m * Dp[i+1] + (m-1)/m*dp[1] + 1, 22 different polygons appear dp[i] = (m-1)/M * Dp[i+1] + 1/m * (dp[1] + dp[2] +. .. + Dp[i]). Find out dp[0].
is mainly the simplification of the formula. They all involve both I and i+1 before and after. The expression of dp[i+1] is then linked, and the difference between the two items in the 22 is found to be geometric series.
pid=4035 ">hdu 4035
This problem is really hard to push. It is very obvious that there is no ring in the tree to find the probability.
Dp[i] said in the room I go out of expectations, then for the leaf node is very good push, it just has a father,dp[i] = ki * dp[1] + ei * 0 + (1-ki-ei) * (Dp[fa[i]] + 1). For non-leaf nodes,dp[i] = ki * dp[1] + ei * 0 + (1-ki-ei)/M * (∑dp[Son[i]] + dp[Fa[i]] + 1). Found Dp[i] and fa[i] and Son[i] have a relationship, I and Fa[i] is a parent-child relationship. Son[i] and I are also a parent-child relationship. Can eliminate one, set dp[i] = a[i] * dp[1] + b[i] * Dp[fa[i]] + c[i], substituting the upper type can be removed to the son[i], into a a[i],b[i] and c[i] expression, by recursion can be found dp[1].
Gauss asks for the desired:
HDU 4418
There is a person on the timeline. It had a direction at first. It waits for the probability of moving forward 1~m, when it reaches the end and then returns, moving in the opposite direction. Ask for the desired number of walks to reach the X point. Dp[i] Indicates the desired number of steps to reach the end point at I. Then the transfer equation can be listed dp[i] =∑ (PK * (dp[(x+k)%n] +k)),
Note that some of the points will not arrive, need BFS pretreatment. Then Gauss asks for expectation.
Zjut 1423
A simpler expectation. State transition equation Very well,dp[i] represents the desired number of steps to go when I point to the end. Then Dp[i] =∑1/m*dp[j] + 1,j is the point connected to I. M is the number of points adjacent to I, and the equation set is solved.
As with the above problem, there will be a point that can not reach, need BFS pretreatment, discretization.
Probability DP Summary