expectation, probability problem in ACM

Source: Internet
Author: User
Tags modulus

A simple primer: Click the Open link

Summary of the Great God: Click to open the link zerolock

My topic: Click the Open link

The problem of probability has been done in the previous period.

First, the expectation

The problem of solving expectations is not understood at first. I did a lot of things later.

Example: (have put back)

In 5 products have 4 pieces of genuine, 1 pieces of defective, from any 2 pieces, which contain the number of genuine numbers for the random variable ξ, then ξ 's mathematical expectation eξ is 1.6

In 5 products have 4 pieces of genuine, 1 pieces of defective, from any 2 pieces, which contain the number of genuine numbers for the random variable ξ, then ξ=2 the number of times the mathematical expectation is 1.16

The first example is the expectation of common learning, the possibility of doing one thing in each outcome. The second example is the problem, the expectation of doing something that takes a number of times.

To solve such problems, the random variables A, b, have the mathematical expectation E (AA+BB) =ae (a) +be (b);
With this formula you can proceed to transform the continuous expectation problem into an independent state, and the probability is equivalent to the A,B;A,B variable. into a linear problem.

e1= (1/3) *e1+ (1/3) *e2+ (1/3) *e3+1①
The next time can go to 2 or 3 or in situ 1, each possible probability is 1/3, note is the next time, so add 1.

There are three types of problems with this type of problem,

1 Non-ring direct recursion solution, probability DP for expected introduction, HDU 4405,POJ 2096,hdu 3853

Zoj 3640 Use a memory search when the endpoint is not easy to determine.

2 Only individual points will form the loop hdu4035 zoj3329

DP[I+K] and Dp[i+j] (dp[i) may be required, such as dp[0] decision
Equivalent to the probability of being pushed down and back to the origin.
Like what
(1):D p[i]=a*dp[i+k]+b*dp[0]+d*dp[i+j]+c;
But Dp[i+k] and dp[0] are all unknown.
At this time, an equation is assumed according to the dp[i] equation:
Like what:
(2):D p[i]=a[i]*dp[i+k]+b[i]*dp[0]+c[i];
Because of the requirement dp[0], so when i=0 but A[0],b[0],c[0] Unknown
Contrast (1) and (2) differences
This time the contrast (1) and (2) found that the difference between the two is dp[i+j]
So according to (2) Seek dp[i+j] and then substituting (1) Eliminate and then compare (2) can get a[i],b[i],c[i]
Then depending on the circumstances according to A[i],b[i],c[i] a[0],b[0],c[0] and then seek dp[0]

3 Gauss elimination Solution .... HDU2262 HDU4418

It's nothing to say.

4 State Compression HDU4336 This is the same as non-cyclic recursion, but it can also be used as a method of repulsion.

The first repulsion theorem is equivalent to finding the sum of multiple sets, but because there is a intersection between 22, it is necessary to cut out the parts that have been cut off repeatedly. When there are more than three sets, the intersection between the three sets is mistakenly clipped, or the intersection between the four is repeated, and so on. So the tolerance theorem is useful, when the number of sets is n, we want to calculate the total sum, we have to calculate all the size of a set, all the size of the intersection of two sets, all of the size of the set intersection of three, until the intersection of n sets of size, the middle even number of subtract, odd number of add up on it. The program of the landlord's allowance theorem represents a large set with the binary of I, and each 1 in I represents a small set. When i++ from 0 to (1<<n-1) is 00 ... 000 to 11 ... 111 The process of change can be exhaustive to all possible intersection cases, and then calculate its size. "Cnt&1" is to judge the parity, by adding or subtraction to calculate the set.
"1.0/sum" is in the calculation of the number of packets, is expected to =NP, so the n= expect to divide the probability, here is expected as long as 1 is OK. Then is the problem of each situation to find probability, for example, a situation is 1101, then is calculated 1000,0100,0001 three events at the same time the probability, because each event is independent, so the probability can be added directly to the total probability.

Independent event Probability addition comprehension: the probability of taking these things at once. and the probability of a single probability

of which f[i]+=in[j]*f[i| ( 1<<J)]; can guarantee the no-direction sex.


Second, probability

poj3744 A road There is a mine, a person to pass through that must have to pass (without stepping), recursion can be solved. Use to quickly power the matrix. Note that the shift uses the original number or it overflows.

poj3071 Soccer probability simulation, pay attention to the binary multiplication process in the three-layer loop.

Codeforces 148D DP means the probability that the Dragon will win in X X, according to test instructions can be easily written out.

poj2151 the probability of doing at least one question per team P1 minus the probability of each team doing a number of 1 to N-1 P2

SGU 495 Test Instructions: N boxes are filled with gifts, m individuals randomly select gifts, and empty boxes are returned to ask for the desired number of selected gifts. M-Individuals are independent. The probability of not being selected for each gift is ((n-1)/n) ^m then the expectation of the number of gifts not selected is N ((n-1)/n) ^m so the answer is  n-n* ((n-1)/n) ^m;

HDU 4089 Dp[i][j] indicates that there is an I person in the queue, the tomato is ranked J, the probability of the event can occur.

When transferring, consider the person who is the head of the team and not the current position in J.

j = = 1:dp[i][1] = p1*dp[i][1] + p2*dp[i][i] + P4;
2<=J<=K:DP[I][J] = P1*dp[i][j] + p2*dp[i][j-1] + p3*dp[i-1][j-1] + P4;
J > K:dp[i][j] = p1*dp[i][j] + p2*dp[i][j-1] + p3*dp[i-1][j-1];

ZOJ 3380

can be DP processing there is no number I position the same probability dp[i][j] means that the current has been placed J position, the use of the first color
That is, Dp[i][j]=dp[i-1][j-k]*c (M (j-k), K) (k<=j&&k<l) means we find the K position to fill in the number I
Because if L>m is bound to be no solution, L>M/2 can be directly used in combination counting, time to reduce by half of the number is very large, there is no modulus, a large number of processing

A simple primer: Click the Open link

Summary of Kuangbin: Click to open link

My topic: Click the Open link

The problem of probability has been done in the previous period.

First, the expectation

The problem of solving expectations is not understood at first. I did a lot of things later.

Example: (have put back)

In 5 products have 4 pieces of genuine, 1 pieces of defective, from any 2 pieces, which contain the number of genuine numbers for the random variable ξ, then ξ 's mathematical expectation eξ is 1.6

In 5 products have 4 pieces of genuine, 1 pieces of defective, from any 2 pieces, which contain the number of genuine numbers for the random variable ξ, then ξ=2 the number of times the mathematical expectation is 1.16

The first example is the expectation of common learning, the possibility of doing one thing in each outcome. The second example is the problem, the expectation of doing something that takes a number of times.

To solve such problems, the random variables A, b, have the mathematical expectation E (AA+BB) =ae (a) +be (b);
With this formula you can proceed to transform the continuous expectation problem into an independent state, and the probability is equivalent to the A,B;A,B variable. into a linear problem.

e1= (1/3) *e1+ (1/3) *e2+ (1/3) *e3+1①
The next time can go to 2 or 3 or in situ 1, each possible probability is 1/3, note is the next time, so add 1.

There are three types of problems with this type of problem,

1 Non-ring direct recursion solution, probability DP for expected introduction, HDU 4405,POJ 2096,hdu 3853

Zoj 3640 Use a memory search when the endpoint is not easy to determine.

2 Only individual points will form the loop hdu4035 zoj3329

DP[I+K] and Dp[i+j] (dp[i) may be required, such as dp[0] decision
Equivalent to the probability of being pushed down and back to the origin.
Like what
(1):D p[i]=a*dp[i+k]+b*dp[0]+d*dp[i+j]+c;
But Dp[i+k] and dp[0] are all unknown.
At this time, an equation is assumed according to the dp[i] equation:
Like what:
(2):D p[i]=a[i]*dp[i+k]+b[i]*dp[0]+c[i];
Because of the requirement dp[0], so when i=0 but A[0],b[0],c[0] Unknown
Contrast (1) and (2) differences
This time the contrast (1) and (2) found that the difference between the two is dp[i+j]
So according to (2) Seek dp[i+j] and then substituting (1) Eliminate and then compare (2) can get a[i],b[i],c[i]
Then depending on the circumstances according to A[i],b[i],c[i] a[0],b[0],c[0] and then seek dp[0]

3 Gauss elimination Solution .... HDU2262 HDU4418

It's nothing to say.

4 State Compression HDU4336 This is the same as non-cyclic recursion, but it can also be used as a method of repulsion.

The first repulsion theorem is equivalent to finding the sum of multiple sets, but because there is a intersection between 22, it is necessary to cut out the parts that have been cut off repeatedly. When there are more than three sets, the intersection between the three sets is mistakenly clipped, or the intersection between the four is repeated, and so on. So the tolerance theorem is useful, when the number of sets is n, we want to calculate the total sum, we have to calculate all the size of a set, all the size of the intersection of two sets, all of the size of the set intersection of three, until the intersection of n sets of size, the middle even number of subtract, odd number of add up on it. The program of the landlord's allowance theorem represents a large set with the binary of I, and each 1 in I represents a small set. When i++ from 0 to (1<<n-1) is 00 ... 000 to 11 ... 111 The process of change can be exhaustive to all possible intersection cases, and then calculate its size. "Cnt&1" is to judge the parity, by adding or subtraction to calculate the set.
"1.0/sum" is in the calculation of the number of packets, is expected to =NP, so the n= expect to divide the probability, here is expected as long as 1 is OK. Then is the problem of each situation to find probability, for example, a situation is 1101, then is calculated 1000,0100,0001 three events at the same time the probability, because each event is independent, so the probability can be added directly to the total probability.

Independent event Probability addition comprehension: the probability of taking these things at once. and the probability of a single probability

of which f[i]+=in[j]*f[i| ( 1<<J)]; can guarantee the no-direction sex.


Second, probability

poj3744 A road There is a mine, a person to pass through that must have to pass (without stepping), recursion can be solved. Use to quickly power the matrix. Note that the shift uses the original number or it overflows.

poj3071 Soccer probability simulation, pay attention to the binary multiplication process in the three-layer loop.

Codeforces 148D DP means the probability that the Dragon will win in X X, according to test instructions can be easily written out.

poj2151 the probability of doing at least one question per team P1 minus the probability of each team doing a number of 1 to N-1 P2

SGU 495 Test Instructions: N boxes are filled with gifts, m individuals randomly select gifts, and empty boxes are returned to ask for the desired number of selected gifts. M-Individuals are independent. The probability of not being selected for each gift is ((n-1)/n) ^m then the expectation of the number of gifts not selected is N ((n-1)/n) ^m so the answer is  n-n* ((n-1)/n) ^m;

HDU 4089 Dp[i][j] indicates that there is an I person in the queue, the tomato is ranked J, the probability of the event can occur.

When transferring, consider the person who is the head of the team and not the current position in J.

j = = 1:dp[i][1] = p1*dp[i][1] + p2*dp[i][i] + P4;
2<=J<=K:DP[I][J] = P1*dp[i][j] + p2*dp[i][j-1] + p3*dp[i-1][j-1] + P4;
J > K:dp[i][j] = p1*dp[i][j] + p2*dp[i][j-1] + p3*dp[i-1][j-1];

ZOJ 3380

can be DP processing there is no number I position the same probability dp[i][j] means that the current has been placed J position, the use of the first color
That is, Dp[i][j]=dp[i-1][j-k]*c (M (j-k), K) (k<=j&&k<l) means we find the K position to fill in the number I
Because if L>m is bound to be no solution, L>M/2 can be directly used in combination counting, time to reduce by half of the number is very large, there is no modulus, a large number of processing

expectation, probability problem in ACM

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.