BZOJ 3093: [Fdu校赛2012] A Famous Game

3093: [Fdu校赛2012] A Famous Game

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 248  Solved: 133
[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

分析:

代码:

#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

转载于:https://www.cnblogs.com/neighthorn/p/6440645.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/456380.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Python第三方库的安装及路径查看总结

文章目录1、python第三方库的四种安装方法2、更换安装的第三方库的镜像源3、如何查看查看python安装路径以及pip安装的包列表及路径3.1、Linux环境下查看Python路径3.2、查看使用pip安装的软件包3.3、Windows 环境 查看Python路径实际工作中&#xff0c;经常会在公司的服务器中…

解决 Cannot open D:\Program Files\Anaconda3\Scripts\pip-script.py 问题

报错&#xff1a; Collecting pip Using cached https://files.pythonhosted.org/packages/30/db/9e38760b32e3e7f40cce46dd5fb107b8c73840df38f0046d8e6 514e675a1/pip-19.2.3-py2.py3-none-any.whl Installing collected packages: pip Found existing installation: pi…

解决:flask-sqlalchemy.exc.DataError: (pymysql.err.DataError) (1406数据库字段超出长度错误)

这个问题是说数据库user的password字段长度超出&#xff0c;修改长度后&#xff0c; 硬核方法删除migrations 文件夹 然后删除数据库中模型表格 python manage.py db init python manage.py db migrate python manage.py dbupgrate 三连击后&#xff0c;在重新运行后方能生…

Android应用程序结构解析

界面布局文件 <?xml version"1.0" encoding"utf-8"?> 声明了XML的版本号和编码方式 <RelativeLayout>:声明本界面采用的布局为RelativeLayout相对布局&#xff0c;该标签下定义了诸如 layout_width/layout_height和paddingLeft相对布局等…

浅谈开发中的MVVM模式及与MVP和MVC的区别

2019独角兽企业重金招聘Python工程师标准>>> 我记得前段时间分享了一篇文章《 浅谈Andorid开发中的MVP模式》&#xff08;点击可跳转&#xff09;&#xff0c;反响不错&#xff0c;为了进一步介绍MVVM模式&#xff0c;还提前分享了实现Android中MVVM模式的一个关键技…

Azkaban简介及安装教程

前言&#xff1a; 最近在实际工作中玩到了Azkaban&#xff0c;虽然之前有简单的接触&#xff0c;但是真正用到的时候&#xff0c;才能体会到这个工具的实用性有多强。下面就写个系列文章来记录下azkaban从简介及安装配置再到简单使用的一个过程。 1、概述 1.1、为什么需要工…

面向对象:实例化的对象调用类方法 db.Column()

请问 类的对象调用另一个类的对象 是什么意思&#xff1f;&#xff1f;&#xff1f; from flask_sqlalchemy import SQLAlchemydb SQLAlchemy()class User(db.Model):__tablename__ usersid db.Column(db.Integer, primary_keyTrue)username db.Column(db.String…

WatiN-Html元素的操作

自动化测试&#xff0c;何为自动化测试&#xff0c;简单点说就是机器代替人工操作&#xff0c;那么WatiN实现Web应用在浏览器上的自动化就需要模拟人工点击、输入、选择、拖放等等操作&#xff0c;在这些操作中会触Html元素的onclick、onchange、onmousemove等事件。在WatiN中提…

azkaban的操作指南

前言&#xff1a; 最近在实际工作中玩到了Azkaban&#xff0c;虽然之前有简单的接触&#xff0c;但是真正用到的时候&#xff0c;才能体会到这个工具的实用性有多强&#xff0c;总结下真个操作过程。在总结整个操作过程之前先简单描述下工作流调度系统的优势。 1、工作流调度…

创建对象方法之增

# 1. 创建模型对象 user User() # 2. 给对象赋值 user.username username user.password pwd user.phone phone # 3. 向数据库提交数据 db.session.add(user) db.sessio…

ActiveMq使用笔记

java JMS技术 .1. 什么是JMS JMS即Java消息服务&#xff08;Java Message Service&#xff09;应用程序接口是一个Java平台中关于面向消息中间件&#xff08;MOM&#xff09;的API&#xff0c;用于在两个应用程序之间&#xff0c;或分布式系统中发送消息&#xff0c;进行异步…

导入Anaconda中的第三方库运行时报错:ImportError: Missing required dependencies ['pandas']

今天碰到一个大坑&#xff0c;花了大半天才搞明白问题出在哪来。事情的经过是这样的&#xff1a;博主下午手贱把已将装好anaconda2给卸载了&#xff08;同时装了2和3&#xff09;&#xff0c;然后再次安装anconda2后&#xff0c;却发现配置完pycharm的解释器后&#xff0c;代码…

BZOJ2005 NOI2010 能量采集 欧拉函数

题意&#xff1a;求$\sum\limits_{i 1}^N {\sum\limits_{j 1}^M {f(i,j)} } $&#xff0c;其中f(i,j)(0,0)与(i,j)连线上点的数量 题解&#xff1a; 如果一个点(x,y)在(0,0)与(x,y)的连线上&#xff0c;则有gcd(x,y)gcd(x,y)。因此f(i,j)(gcd(i,j)gcd(i,j))且i<i,j<j的…

通过__tablename__ = 'xxx' #定义表名

from datetime import datetimefrom exts import dbclass User(db.Model):__tablename__ user1 #定义表名id db.Column(db.Integer,primary_keyTrue,autoincrementTrue)username db.Column(db.String(10), nullableTrue)password db.Column(db.String(256), nullableTrue)p…

python子类继承父类特性,pycharm上面已经提示继承了,为什么会报没有该特性的错误?

因为在子类里覆盖了父类的__init__ 如果需要调用父类用super class A(object):def __init__(self):self.a 1def fun(self):print self.aclass B(A):def __init__(self):self.b 2super(B, self).__init__()def fun(self):print self.aprint self.bB().fun()

Hadoop伪分布安装详解(一)

注&#xff1a;以下截图针对Ubuntu操作系统&#xff0c;对Centos步骤类似。请读者选择不同镜像即可。 第一部分&#xff1a;VMware WorkStation10 安装 1.安装好VMware10虚拟机软件并下载好Ubuntu16.04 LTS 64位版的镜像包 2.打开VMware10虚拟机软件&#xff0c;选择“创建新的…

C++_const常成员作用

介绍 常成员是什么 1.常成员关键词为&#xff1a;const 2.常成员有&#xff1a;常成员变量、常成员函数、常成员对象 常成员有什么用 1.常成员变量&#xff1a;用于在程序中定义不可修改内部成员变量的函数 2.常成员函数&#xff1a;只能够访问成员变量&#xff0c;不可以修改成…

Python开发中收集的一些常用功能Demo

文章目录目录&#xff1a;前言&#xff1a;1、Python判断文件是否存在的几种方法&#xff1a;1.1、使用os模块1.2、使用Try语句&#xff08;比较严谨的写法&#xff09;1.3、使用pathlib模块2、Python中写入List到文本中并换行的方法3、Python按行读取文件的几种简单实现方法3.…

Unlicensed ARC session – terminating!

问题描述 近日&#xff0c;发现ArcGIS10.4中存在很多bug&#xff0c;而且费了好多时间去测试它&#xff0c;最终决定改用10.1。在降级程序时遇到许可问题。 重装ArcGIS10.1后&#xff0c;打开工程&#xff0c;所有引用都自动映射&#xff0c;没报任何错误&#xff0c;清理重新生…

SQLAlchemy - Column详解

SQLAlchemy - Column详解 Column常用参数&#xff1a; default&#xff1a;默认值 nullable&#xff1a;是否可有 primary_key&#xff1a;是否为主键 unique&#xff1a;是否唯一 autoincrement&#xff1a;是否自动增长 onupdate&#xff1a;更新的时候执行的函数 name&…