Birthday Paradox
Birthday Paradox
Sometimes some mathematical results are hard to believe. One of the common problems is the birthday paradox. Suppose you are in a party where there are 23 people including you. What is the probability that at least two people in the party have same birthday? Surprisingly the result is more than 0.5. Now here you have to do the opposite. You have given the number of days in a year. Remember that you can be in a different planet, for example, in Mars, a year is 669 days long. You have to find the minimum number of people you have to invite in a party such that the probability of at least two people in the party have same birthday is at least 0.5.
Input
Input starts with an integer T (≤ 20000), denoting the number of test cases.
Each case contains an integer n (1 ≤ n ≤ 105) in a single line, denoting the number of days in a year in the planet.
Output
For each case, print the case number and the desired result.
Sample Input
2
365
669
Sample Output
Case 1: 22
Case 2: 30
题意 生日悖论
题解 百度百科关于生日悖论
水题。
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<cstring>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
int Case=1;
while(t--)
{
double n;
scanf("%lf",&n);
double sum=1;
int x=0;
while(sum>0.5)
{
sum *=(n-x)/n;
x++;
}
printf("Case %d: %d\n",Case++,x-1);
}
return 0;
}
Birthday Paradox的更多相关文章
- Codeforces 711E ZS and The Birthday Paradox
传送门 time limit per test 2 seconds memory limit per test 256 megabytes input standard input output st ...
- codeforces 711E E. ZS and The Birthday Paradox(数学+概率)
题目链接: E. ZS and The Birthday Paradox. time limit per test 2 seconds memory limit per test 256 megaby ...
- 教程-(SQL DBE、ADO连接)+(Firebird火鸟+DbExpress)+(VF DBF数据库)+(DB Paradox)
DBE 连接SQL Server显然用ADO或DBEXPRESS更有优势,起码连接起来比较方便. BDE的话可以用如下方法:(以下以Delphi7为例,其它版本的DELPHI请自己摸索一下,不过基本相 ...
- 数学概念——F 概率(经典问题)birthday paradox
F - 概率(经典问题) Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit S ...
- ZS and The Birthday Paradox
ZS and The Birthday Paradox 题目链接:http://codeforces.com/contest/711/problem/E 数学题(Legendre's formula) ...
- Barber paradox
According to Wikipedia, the well known barber paradox states like this: The barber is the "one ...
- Codeforces 711E ZS and The Birthday Paradox 数学
ZS and The Birthday Paradox 感觉里面有好多技巧.. #include<bits/stdc++.h> #define LL long long #define f ...
- Codeforces Round #369 (Div. 2) E. ZS and The Birthday Paradox 数学
E. ZS and The Birthday Paradox 题目连接: http://www.codeforces.com/contest/711/problem/E Description ZS ...
- C# 连接Paradox DB
Paradox数据库是一个成名于15年前的数据库,那时候Borland公司还存在.最近客户提出需求,要在一套用了12年+的应用程序上作些功能更改.这套应用程序使用Delphi+Paradox数据库. ...
- H - Birthday Paradox (生日悖论)
点击打开链接 Sometimes some mathematical results are hard to believe. One of the common problems is the bi ...
随机推荐
- ADODB.Stream在进行文件上传时报错
最近在做web项目,有个控件是上传材料文件和文件夹,本地运行正常,放到服务器上,一直报错:AutoRuntime服务器无法创建..... 解决方法: 1.配置ie浏览器的安全级别 2.修改ie浏览器对 ...
- jmeter压测配置
windows上面修改最大使用端口数和time_await等待时间 注册表需要添加两个配置,位置:HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ S ...
- <Android 基础(二)> BroadcastReceiver
介绍 BroadcastReceiver:广播接收者,很形象,广播发送,类比生活中的广播,有能力听得到的都可以介绍到这个信息,然后在大脑中反映.对应到Android中就是SendBroadcast和o ...
- 微信公众平台网页开发实战--3.利用JSSDK在网页中获取地理位置(HTML5+jQuery)
复制一份JSSDK环境,创建一份index.html文件,结构如图7.1所示. 图7.1 7.1节文件结构 在location.js中,封装“getLocation”接口,如下: 01 wxJSSD ...
- LeetCode Excel Sheet Column Number 表列数
题意:天啊!我竟然看不懂题意,还去翻别人的代码才懂!给定一个字符串,求该字符串二十六进制的总值. 思路:'A'~'Z'就是1到26,"AA"=26+1=27,"BA&qu ...
- thinkphp 3.2.3版本学习笔记
2.开启调试模式,有什么作用?(默认关闭,在ThinkPHP.php 33行左右) (1)非法调用的时候,有详细的报错信息,便于调试 (2)APP_DEBUG为true并且缓存文件存在,走缓存文件,否 ...
- linux 命令——2 cd (转)
Linux cd 命令可以说是Linux中最基本的命令语句,其他的命令语句要进行操作,都是建立在使用 cd 命令上的. 所以,学习Linux 常用命令,首先就要学好 cd 命令的使用方法技巧. 1. ...
- TFS看板的设计
列 产品开发的整个流程如下图,将流程配置到看板的列: 需求池-->就绪-->开发-->测试-->待验收 -->待发布 -->已关闭 一般将Bug和需求放在一块看版上 ...
- [转]Cannot deserialize the current JSON array (e.g. [1,2,3]) into type
string content =[{"id": 3636, "is_default": true, "name": "Unit&q ...
- Trie:字典树
简介 \(Trie\),又称字典树或前缀树,是一种有序树状的数据结构,用于保存关联数组,其中的键值通常是字符串. 作用 把许多字符串做成一个字符串集合,并可以对其进行快速查找(本文以求多少个单词是一个 ...