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的更多相关文章

  1. Codeforces 711E ZS and The Birthday Paradox

    传送门 time limit per test 2 seconds memory limit per test 256 megabytes input standard input output st ...

  2. 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 ...

  3. 教程-(SQL DBE、ADO连接)+(Firebird火鸟+DbExpress)+(VF DBF数据库)+(DB Paradox)

    DBE 连接SQL Server显然用ADO或DBEXPRESS更有优势,起码连接起来比较方便. BDE的话可以用如下方法:(以下以Delphi7为例,其它版本的DELPHI请自己摸索一下,不过基本相 ...

  4. 数学概念——F 概率(经典问题)birthday paradox

    F - 概率(经典问题) Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit S ...

  5. ZS and The Birthday Paradox

    ZS and The Birthday Paradox 题目链接:http://codeforces.com/contest/711/problem/E 数学题(Legendre's formula) ...

  6. Barber paradox

    According to Wikipedia, the well known barber paradox states like this: The barber is the "one ...

  7. Codeforces 711E ZS and The Birthday Paradox 数学

    ZS and The Birthday Paradox 感觉里面有好多技巧.. #include<bits/stdc++.h> #define LL long long #define f ...

  8. 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 ...

  9. C# 连接Paradox DB

    Paradox数据库是一个成名于15年前的数据库,那时候Borland公司还存在.最近客户提出需求,要在一套用了12年+的应用程序上作些功能更改.这套应用程序使用Delphi+Paradox数据库. ...

  10. H - Birthday Paradox (生日悖论)

    点击打开链接 Sometimes some mathematical results are hard to believe. One of the common problems is the bi ...

随机推荐

  1. win7,docker安装后,创建虚拟机分配不了ip错误 err: exit status 255

    问题 win7装docker真麻烦,不如家里的win10爽.另外明明这是个很简单的操作,但是国内的解决方法有点落后,所以我写了个傻瓜式的. 有兴趣的可以直接看issue https://github. ...

  2. JavaSE_3_面向对象

    1.wait方法底层原理 wait是object中的方法,可以暂停线程,会释放对象锁,不像sleep方法,线程休眠期依然持有锁,通过调用notify或notifyAll方法唤醒线程. lock.wai ...

  3. OpenFirewall

    1.写一份json文件:将要添加防火墙例外的应用程序和端口写入到json文件中 2.打开防火墙,读取json文件添加例外 /// <summary> /// Firewall.xaml 的 ...

  4. Android商城开发系列(十)—— 首页活动广告布局实现

    在上一篇博客当中,我们讲了频道布局的实现,接下来我们讲解一下活动广告布局的实现,效果如下图: 这个是用viewpager去实现的,新建一个act_item.xml,代码如下所示: <?xml v ...

  5. 您H1B身份的申请或H1B延期的申请提交对地方了吗?

    由于H1B配额的短缺,任何关于移民局对H1B申请的改动对马上要申请H1B的外国学生或专业人士来说都很重要.美国移民局在2007年3月5号发布了关于更改接收H1B身份申请或H1B延期申请的新政策. 申请 ...

  6. STL中的map和hash_map

    以下全部copy于:http://blog.chinaunix.net/uid-26548237-id-3800125.html 在网上看到有关STL中hash_map的文章,以及一些其他关于STL ...

  7. 基于PowerShell的Lync Server管理 使用C#

    这里所说的Lync Server管理,指通过C#管理Lync账号的启用,禁用,开启账户的语音功能. Lync服务器安装后,会自动创建一个用于远程管理的应用程序,通过IIS查看,其应用程序名为: Lyn ...

  8. Windows Azure 入门 -- VS 2015部署 ASP.NET网站(项目) 与 数据库

    Windows Azure 入门 -- 部署 ASP.NET网站(项目) 与数据库 https://www.dotblogs.com.tw/mis2000lab/2015/12/24/windowsa ...

  9. javascript面向对象继承和原型

    一.理解什么是对象:任何东西都可以是对象,对象就是一组无序属性的集合 对象具有属性和方法1.1 属性的类型属性内部又定义了两种属性:数据属性和访问器属性 (1)数据属性:有4个描述的行为 Config ...

  10. java Vamei快速教程21 事件响应

    作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! 在GUI中,我们看到了如何用图形树来组织一个图形界面.然而,这样的图形界面是静态的 ...