3093: [Fdu校赛2012] A Famous Game

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 242  Solved: 129
[Submit][Status][Discuss]

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

[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

 

[Submit][Status][Discuss]

题意:已知有N个球,其中K个是蓝的,其余的是红的。K的范围是0到N,并且等概率。某人从其中随机取球(不放回),现在取出了P个,其中Q个是蓝色的,求下一个球是蓝色的概率。

今天学习的概率初等内容,然而蒟蒻的我只推出了$O(N)$的做法,式子经ZXR大佬化简后得到——$\frac{q+1}{p+2}$,呵呵,怪不得时限给1s。

 #include <cstdio>

 signed main(void)
{
int p, q, c = ; while (scanf("%*d%d%d", &p, &q) != EOF)
printf("Case %d: %.4lf\n", ++c, 1.0*(q+)/(p+));
}

@Author: YouSiki

BZOJ 3093: [Fdu校赛2012] A Famous Game的更多相关文章

  1. 【BZOJ】3093: [Fdu校赛2012] A Famous Game

    http://www.lydsy.com/JudgeOnline/problem.php?id=3093 题意:n个球(红和蓝两种),等概率有1~n个红球.首先取出p个球且这p个球里边有q个红球,问从 ...

  2. Bzoj3093 [Fdu校赛2012] A Famous Game

    Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 251  Solved: 136 Description Mr. B and Mr. M like to ...

  3. 【BZOJ】【3093】【FDU校赛2012】A Famous Game

    概率论 神题不会捉啊……挖个坑先 orz 贾教 & QuarterGeek /********************************************************* ...

  4. 2016 华南师大ACM校赛 SCNUCPC 非官方题解

    我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...

  5. SCNU省选校赛第二场B题题解

    今晚的校赛又告一段落啦,终于"开斋"了! AC了两题,还算是满意的,英语还是硬伤. 来看题目吧! B. Array time limit per test 2 seconds me ...

  6. 2014上半年acm总结(1)(入门+校赛)

    大一下学期才开始了acm,不得不说有一点迟,但是acm确实使我的生活充实了很多,,不至于像以前一样经常没事干=  = 上学期的颓废使我的c语言学的渣的一笔..靠考前突击才基本掌握了语法 寒假突然醒悟, ...

  7. 2017CUIT校赛-线上赛

    2017Pwnhub杯-CUIT校赛 这是CUIT第十三届校赛啦,也是我参加的第一次校赛. 在被虐到崩溃的过程中也学到了一些东西. 这次比赛是从5.27早上十点打到5.28晚上十点,共36小时,中间睡 ...

  8. HZNU第十二届校赛赛后补题

    愉快的校赛翻皮水! 题解 A 温暖的签到,注意用gets #include <map> #include <set> #include <ctime> #inclu ...

  9. 校赛F

    问题描述 例如对于数列[1 2 3 4 5 6],排序后变为[6 1 5 2 4 3].换句话说,对于一个有序递增的序列a1, a2, a3, ……, an,排序后为an, a1, an-1, a2, ...

随机推荐

  1. MOD 模除运算符

    用于奇数和偶数的校验,星期几的计算,以及其它专门的计算.

  2. 人工智能AI芯片与Maker创意接轨 (中)

    在人工智能AI芯片与Maker创意接轨(上)这篇文章中,介绍人工智能与深度学习,以及深度学习技术的应用,了解内部真实的作业原理,让我们能够跟上这波AI新浪潮.系列文来到了中篇,将详细介绍目前市面上的各 ...

  3. mac zsh不自动加载~/.bashrc

    修改了bashrc, 新开一个终端都要source一下才起作用. 网上有说需要在 . bash_profile加载一次.bashrc. 但是这个和我的问题不一样. 我用的是zsh,需要修改~/.zsh ...

  4. CentOS删除安装的程序

    以mysql举例: 首先查询安装包: rpm -qa|grep mysql 查询到的一个结果为:mysql-community-libs-5.7.13-1.el6.x86_64 yum 删除 yum ...

  5. React 之容器组件和展示组件相分离解密

    Redux 的 React 绑定库包含了 容器组件和展示组件相分离 的开发思想.明智的做法是只在最顶层组件(如路由操作)里使用 Redux.其余内部组件仅仅是展示性的,所有数据都通过 props 传入 ...

  6. nodejs的Cannot find module 'body-parser'

    http://blog.csdn.net/u014345860/article/details/77769253

  7. Javascript开发者 常用知识

    Javascript是一种日益增长的语言,特别是现在ECMAScript规范按照每年的发布时间表发布.伴随着这门语言的规模化和快速发展,掌握JS(不仅仅是jQuery)的重要性,变得更加重要. 这不是 ...

  8. Scrum Meeting 10.28

    今天大部分同学仍停留在学习阶段,进度快的同学已经在配置SQLserver. 成员 今日完成任务 明日计划 所用时间 徐越 配置SQLserver,试用java程序连接数据库 学习servlet,htt ...

  9. OO学习第二阶段总结

    面向对象课程的第二个阶段结束了,作业们由简单的玩具模式步入到复杂的多线程地狱模式,由之前的算法简单实现有坑转变成算法复杂实现有很大的坑.一个最重要的心得就是一定要在动手敲代码实现之前对整个程序的实现做 ...

  10. 项目Beta冲刺(团队)第六天

    1.昨天的困难 可以获得教务处通知栏的15条文章数据了,但是在显示的时候出了问题. 私信聊天的交互还没研究清楚 2.今天解决的进度 成员 进度 陈家权 研究私信模块 赖晓连 研究问答模块 雷晶 研究服 ...