BZOJ 3093: [Fdu校赛2012] A Famous Game
Posted You Siki
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了BZOJ 3093: [Fdu校赛2012] A Famous Game相关的知识,希望对你有一定的参考价值。
3093: [Fdu校赛2012] A Famous Game
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 242 Solved: 129
[Submit][Status][Discuss]
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
题意:已知有N个球,其中K个是蓝的,其余的是红的。K的范围是0到N,并且等概率。某人从其中随机取球(不放回),现在取出了P个,其中Q个是蓝色的,求下一个球是蓝色的概率。
今天学习的概率初等内容,然而蒟蒻的我只推出了$O(N)$的做法,式子经ZXR大佬化简后得到——$\frac{q+1}{p+2}$,呵呵,怪不得时限给1s。
1 #include <cstdio> 2 3 signed main(void) 4 { 5 int p, q, c = 0; 6 7 while (scanf("%*d%d%d", &p, &q) != EOF) 8 printf("Case %d: %.4lf\n", ++c, 1.0*(q+1)/(p+2)); 9 }
@Author: YouSiki
以上是关于BZOJ 3093: [Fdu校赛2012] A Famous Game的主要内容,如果未能解决你的问题,请参考以下文章
P3093 [USACO13DEC]牛奶调度Milk Scheduling——贪心
前端学习(3093):vue+element今日头条管理-反馈
前端学习(3093):vue+element今日头条管理-反馈