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. oracle表空间的创建及dmp 文件的导入

    --用oracle系统权限的账号 登陆 -- 1.创建用户 create user u_name identified by "u_password"; --2.赋予权限 gran ...

  2. Linux系统中时间区域和API

    1.问题 在开发云平台程序的时候,经常会碰到时间区域转换的问题.比如,任何网络存储的文档的metadata都自己记录了编辑时间.但是,云平台记录时需要把这个时间转成标准时间,便于管理.但是用户使用的时 ...

  3. 如何解决zabbix snmp异常超时、不稳定、时通时断:Timeout

    针对平时工作中,zabbix snmp出现异常超时.不稳定.时通时断:Timeout while connecting 等的情况,以下我将以使用乐维监控为例,进行解决方案的详细叙述.   一.问题:设 ...

  4. 高可用OpenStack(Queen版)集群-8.Horizon集群

    参考文档: Install-guide:https://docs.openstack.org/install-guide/ OpenStack High Availability Guide:http ...

  5. Linux 文件系统 -- 文件权限简介

    一.文件权限 使用 ls -l 命令可以查看文件的具体属性: 如图所示,第一列所示告诉了用户一个文件的类型和权限信息: 1)第一个字符 "d",表明该文件是一个目录文件: 2)r ...

  6. 满帮集团CEO:未来将向“智慧型”公司转变,要成为一家生态公司

    谁都想成为下一个滴滴.显然,王刚也希望在物流业,货车帮与运满满在合并后,能够企及滴滴的高度. 货车帮与运满满,都曾是货运物流领域的翘楚,也因为业务的竞争关系有过水火不容厮杀.但最终还是在资本与地方政府 ...

  7. nice和renice命令详解

    基础命令学习目录首页 进程调度是linux中非常重要的概念.linux内核有一套高效复杂的调度机制,能使效率极大化,但有时为了实现特定的要求,需要一定的人工干预.比如,你希望操作系统能分配更多的CPU ...

  8. Redux和React-Redux的实现(一):Redux的实现和context

    react使用redux做状态管理,实现多个组件之间的信息共享,解决了父子组件.兄弟组件之间的复杂通信问题.vue有vuex,总之是一种flux的思想.react提供了react-redux这个库,一 ...

  9. Visual Studio AI配置环境

    参考链接:http://www.cnblogs.com/ms-uap/p/9123033.html 背景: 1.能联网的电脑:Win7 64 SP1 2.鼠标.键盘.显示器好使 3.已安装VS2010 ...

  10. 【探路者】Final发布

    [探路者]团队项目final发布:贪吃蛇 [探路者]贪吃蛇 final发布展示(视频)链接: http://v.youku.com/v_show/id_XMzIxMDM2MTQ1Ng==.html?s ...