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.pswp.cn/news/456380.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/456380.shtml
英文地址,請注明出處:http://en.pswp.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&…