Interestingly, the probability of problems (by plane, playing cards) interview process

Playing cards

54 poker, the average three, king size probability in the hands of a man given to

The number of combinations can be directly calculated, we put out two cards, is 16,18,18

The man is equivalent to 16 to 52 cards in the take twelve, because two people are 18, so go heavy

Molecule can be determined as C (52,16) * C (36,18) * C (18,18) * 3

Similarly seeking denominator C (54,18) * C (36,18) * C (18,18)

The equation is then the number of combinations, i.e. 18 * 17 * 3 / (54 * 53) = 17/53

#include<bits/stdc++.h>
using namespace std;
const int MD=1e9+7,N=2e6+5;
int f[N],v[N];
void Init()
{
    v[0]=v[1]=f[0]=f[1]=1;
    for(int i=2; i<N; i++) f[i]=1LL*f[i-1]*i%MD,v[i]=1LL*v[MD%i]*(MD-MD/i)%MD;
    for(int i=2; i<N; i++) v[i]=1LL*v[i-1]*v[i]%MD;
}
int C(int n,int m)
{
    if(m<0||m>n) return 0;
    return 1LL*f[n]*v[m]%MD*v[n-m]%MD;
}
int main()
{
    Init();
    int n,m;
    while (cin>>n>>m)cout<<C(n,m)<<"\n";
    return 0;
}
Linear combination of several requirements inversing Template

Of course, some people did not want to write the number of combinations, molecular written in C (52,18) * C (34,18) * C (16,16) * 3 is also possible, but the common denominator is not so good-looking, value is the same

King was able to get to someone as a reference, and have to be able to get Wang. King can appear anywhere in the 3 × 18, Wang must appear in the same hands, but it appears a king in the (total 17) can not occur.
3 × 18 × 17 i.e. 
a total of 3 × 18 × 53 case, i.e., the same position is not Wang king. This is the younger brother of rabbit practice, I think it is very clever, oh

The question becomes extended, a person holding 20, the other two people take 17. Landlords of the real situation hhhh

Of course, landlords probability is higher, but how much is it specific, we can look at

The denominator is relatively simple, first write the denominator C (54,20) * C (34,17) * C (17,17) * 3

The three men could card is 181 717 and 201 715

Write molecule is C (52,18) * C (34,17) * C (17,17) * 3 + C (52,20) * (32,15) * C (17,17) * 6

Points can be calculated approximately 0.434661, above that value is 0.320755

Some students think a first glance is 1/3, but in fact go wrong

For example, two cards, some people think it is 1/2, in fact, is a slightly smaller number than 1/2, 16/53.

Why this happen, because was occupying, you have this card will take up that position, it can not take on directly the probability

We can consider the six cards given to two people, this works out to 2/5, in fact, the formula is (n / m-1) / (number of heaps n represents the number of cards, m for minutes) (n-1)

Four people, two king size remove the remaining 52 cards. A hearts Q spades and A at the same time to get the probability of a person, and that you will soon figure out 12/51, and next door it was still autistic

But as long as you do not or can not be divided equally split the points will be about annoying problem, certainly before bisects this number is less than 1 / m, after not bisect certainly larger than 1 / m, which can be considered magical inequality bar

100 people travel by plane, the first passenger in the seat to sit down and pick any one, the first 100 people to sit their probability of correct seat is?

They were to get a seat from No. 100 to No. 1, these passengers will check in numerical order and should condemnation, if they find the corresponding number of seats to sit by others, it will just pick the remaining empty seats in a sit. Now suppose No. 1 passenger mad (others not crazy), he will pick a seat to sit down, asked 100 seats: 100 people sit in their probability of correct seat is how much? (Can also be extended to the case of n n-seat passengers)
 
In fact, it is a recursive problem
A passenger a position 100%
2 passengers 2 position of your state and the first person about 50%
3 3 position of the first passengers to sit on, and that is returned to the state 2
         The first person account your location
         The first person to sit another person's position, or state 2 is how much this probability is (1/6 + 1/6) * 3, or 50%
4 or so has been going back and forth
Looks like you and just about the first person, the first person of the  [official] personal check, his seat is occupied probability [official] 
 
 
 

Guess you like

Origin www.cnblogs.com/BobHuang/p/11303735.html