HDU 4254 A Famous Game (概率&组合数学公式)

本文探讨了游戏开发中大数据分析的应用,包括如何利用大数据技术优化游戏性能、提升用户体验和进行用户行为分析。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A Famous Game



Time Limit: 2000/1000 MS (Java/Others) 

 Memory Limit: 32768/32768 K (Java/Others)


Problem Description
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 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?

Input
Each test case contains only one line with three integers N, P and Q (2 <= N <= 100,000, 0 <= P <= N-1, 0 <= Q <= P).

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 rounded to four
decimal places.

Sample Input
  
3 0 0 4 2 1

Sample Output
  
Case 1: 0.5000 Case 2: 0.5000
Hint
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.

Source

解析见,但我觉得里面有个公式有点问题。。


完整代码:

/*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;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值