A Famous Game
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 32768/32768 K (Java/Others)
Mr. M knows that there are N+1 possible situations in which the number of red balls is ranged from 0 to N, and we assume the possibilities of the N+1 situations 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 up one more ball out of the bag, what is the possibility that this ball is red?
decimal places.
3 0 0 4 2 1
Case 1: 0.5000 Case 2: 0.5000HintFor 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.
解析见这,但我觉得里面有个公式有点问题。。
完整代码:
/*0ms,260KB*/
#include <cstdio>
int main(void)
{
int T = 0, n, p, q;
while (~scanf("%d%d%d", &n, &p, &q))
printf("Case %d: %.4f\n", ++T, (q + 1.0) / (p + 2));
return 0;
}
1998



被折叠的 条评论
为什么被折叠?



