Reputation: 777
I tried to solve this TopCoder problem: http://community.topcoder.com/stat?c=problem_statement&pm=10863&rd=14150
But, my solution is not good, and I don't understand why.
I understood the solution given there (down page: look for LotteryPyaterochka): http://apps.topcoder.com/wiki/display/tc/SRM+466
So, to sum up my problem:
We are playing a special kind of lottery:
Each ticket in this lottery is a rectangular grid with N rows and 5 columns, where each cell contains an integer between 1 and 5*N, inclusive. All integers within a single ticket are distinct.
The lottery organizers randomly choose 5 distinct integers, each between 1 and 5*N, inclusive. Each possible subset of 5 integers has the same probability of being chosen. These integers are called the winning numbers. A ticket is considered a winner if and only if it has a row which contains at least 3 winning numbers.
We want to know the number of winning ticket (thus, having at least 3 winning number in the same row)
So, I stuck in the following step:
number of ways of choosing the 5 numbers which appear in the 'winning row'.
The topCoder solution says:
(#ways of choosing the 5 numbers which appear in the 'winning row') =
(#ways of choosing the x winning numbers which appear in the 'winning row') * (#ways of choosing 5-x 'non-winning numbers') =
(5 choose x) * ((5N-5) choose (5-x))
Since the number of winning numbers in this row is at least 3, x can be 3 or 4 or 5. So, we have (#ways of choosing the 5 numbers which appear in the 'winning row') =
(5 choose 3) * ((5N-5) choose 2) + (5 choose 4) * ((5N-5) choose 1) + (5 choose 5) * ((5N-5) choose 0))
And what I say:
(#ways of choosing the 5 numbers which appear in the 'winning row') =
(3 number among the 5 winning number) * (2 numbers to complete the row to choose among the 5N-5 non winning number + 2 winning number non chosen before) =
(5N choose 3) * ((5N-3)choose 2)
For N = 10 my method give: (5 choose 3)*(47 choose 2) = 10810
And the topcoder method give: ((5 choose 3)(45 choose 2) + (5 choose 4)(45 choose 1) + (5 choose 5)*(45 choose 0)) = 10126
Why is my method wrong ?
Thanks
Upvotes: 2
Views: 657
Reputation: 500773
Let's say the winning numbers are 1, 2, 3, 4 and 5. Now let's look at the ticket that contains all five numbers in the winning row.
Your method counts that ticket many times, since it's included in the following counts:
1 2 3 + two other numbers
1 2 4 + two other numbers
1 2 5 + two other numbers
1 3 4 + two other numbers
...
The same thing happens to tickets with four winning numbers.
This is the reason why these cases need to be counted separately.
Upvotes: 2