PRLGAME2 - A Famous Game
Mr. B and Mr. M like to play with balls. They have many balls colored in blue and red. Firstly, Mr. B randomly picks up N balls out of them and put them into a bag. Mr. M knows that there are N+1 possible situation which the number of red balls are ranged from 0 to N, and we assume the possibilities of the N+1 situation are the same. But Mr. M does not know which situation occurs. Secondly, Mr. M picks up P balls out of the bag and examines them. There are Q red balls and P-Q blue balls. The question is, if he picks one more ball out of the bag, what is the possibility that this ball is red.
Input
Each test case contains only one line with three integers N, P and Q (2 <= N <= 100,000, 0 <= Q <= P <= N-1).
Output
For each test case, display a single line containing the case number and the possibility of the next ball Mr. M picks out is red. The number should be round to four decimal places.
The judge is "ignoring extra whitespaces".
Example
Input: 3 0 0 4 2 1 Output: Case 1: 0.5000 Case 2: 0.5000
Explanation
For example as the sample test one, there are three balls in the bag. The possibilities of the four possible situations are all 0.25. If there are no red balls in the bag, the possibility of the next ball are red is 0. If there is one red ball in the bag, the possibility is 1/3. If there are two red balls, the possibility is 2/3. Finally if all balls are red, the possibility is 1. So the answer is 0*(1/4)+(1/3)*(1/4)+(2/3)*(1/4)+1*(1/4)=0.5.
hide comments
rrm_2016:
2017-01-03 05:57:49
Is he putting the balls back and then taking out another ball? Last edit: 2017-01-03 05:58:04 |
|
nowuseeme_03:
2016-01-24 22:48:17
Second Case Explaination::(0+1/2+1)1/3==1/2 Last edit: 2016-01-25 22:21:37 |
|
Anant Upadhyay:
2015-09-12 20:52:38
just some paper work and it's done! |
|
Aradhya:
2013-05-28 21:25:46
i tried to make a formula from test cases n it worked :D |
|
lovelotus:
2013-01-19 23:30:50
nice ques on probability n combinations... ;) Last edit: 2013-01-20 00:10:14 |
|
Naman:
2012-09-04 16:16:40
Does he put back the balls he takes out to examine? Because if he does, it's not clear, and the test cases produce same result in either case. If he does not, then answer should be 0.5000 always which it clearly isn't :D |
|
akb:
2012-07-17 15:40:29
How can ans be 0.500 for case 2,please explain... |
|
Kapish Goel:
2012-06-16 18:52:10
can someone explain second tst case?? |
Added by: | Fudan University Problem Setters |
Date: | 2012-05-25 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | lcosvse's own problem, used in FDU Local Contest 2012 |