3093: [Fdu校赛2012] A Famous Game
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 248 Solved: 133
[Submit][Status][Discuss]
Description
Input
Output
Sample Input
4 2 1
Sample Output
Case 2: 0.5000
HINT
[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.
Source
分析:
代码:
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
//by NeighThorn
using namespace std;int n,p,q,cas;signed main(void){cas=0;while(scanf("%d%d%d",&n,&p,&q)!=EOF)printf("Case %d: %.4f\n",++cas,1.0*(q+1)/(1.0*(p+2)));return 0;
}
By NeighThorn