Bzoj3093 [Fdu校赛2012] A Famous Game
Posted SilverNebula
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Bzoj3093 [Fdu校赛2012] A Famous Game相关的知识,希望对你有一定的参考价值。
Submit: 251 Solved: 136
Description
Input
Output
Sample Input
3 0 0
4 2 1
Sample Output
Case 1: 0.5000
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
数学问题 概率
推出来答案就是(q+1)/(p+2)
可能是近一年写过最短的代码
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<queue> using namespace std; const int mxn=100010; int read(){ int x=0,f=1;char ch=getchar(); while(ch<‘0‘ || ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();} while(ch>=‘0‘ && ch<=‘9‘){x=x*10-‘0‘+ch;ch=getchar();} return x*f; } int n,p,q; int main(){ int cas=0; while(scanf("%d%d%d",&n,&p,&q)!=EOF){ printf("Case %d: %.4f\n",++cas,(q+1.0)/(p+2.0)); } return 0; }
以上是关于Bzoj3093 [Fdu校赛2012] A Famous Game的主要内容,如果未能解决你的问题,请参考以下文章
bzoj 1015: [JSOI2008]星球大战starwar
bzoj2806 [Apio2012]dispatching可并堆
P3093 [USACO13DEC]牛奶调度Milk Scheduling——贪心