HDU 4254 A Famous Game
来源:互联网 发布:tcl网络电视进不了系统 编辑:程序博客网 时间:2024/05/16 14:23
J - 1010
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uDescription
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?
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.
decimal places.
Sample Input
3 0 04 2 1
Sample Output
Case 1: 0.5000Case 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.
#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>using namespace std;int main(){ int n,kase=0,p,q; double y; while(scanf("%d%d%d",&n,&p,&q)!=EOF) { printf("Case %d: %.4lf\n",++kase, (q+1.0)/(p+2.0) ); } return 0;}
这题要用页贝斯公式,概率论的内容,该理论一定要好好学,找机会仔细做做
0 1
- HDU 4254 A Famous Game
- HDU 4254A Famous Game
- HDU 4254 A Famous Game (概率&组合数学公式)
- HDU 4254 A Famous Game(概率与期望)
- hdu 4252 A Famous City
- HDU 4255 A Famous Grid
- HDU 4255 A Famous Grid
- HDU 4255 A Famous Grid
- hdu 4255 A Famous Grid
- HDU 4252A Famous City
- HDU 4252 A Famous City
- nyoj-140-A Famous City//hdu-4252-A Famous City
- hdu 4245 A Famous Music Composer--map
- HDU 4252 A Famous City 解题报告
- HDU/HDOJ----4252 A Famous City
- HDU 4225 A Famous Grid bfs
- hdu 42445A Famous Music Composer
- hdu 4248 A Famous Stone Collector
- awk正则表达式
- Lecture 2 Gradient descent
- 第一天
- C++之运算符重载(分数的运算)
- 将数组中的字符按出现次数多少排序输出
- HDU 4254 A Famous Game
- linux与windows调用动态库so dll文件
- Java虚拟机(JVM)中的内存设置详解
- poj1995
- 玩命牛的成长记录(十)——连接数据库
- 第三讲 Gradient descent in practice II: Learning rate
- java 使用正则表达式从网页上提取网站标题 (转载)
- dfgdsfhgdhsd3424536sdrsrg
- c语言合法标识符