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. 《敏捷软件开发:原则、模式与实践(C#版)》源代码下载

    Agile Software Development: Principles, Patterns and Practice (C# Edition)  Source Code 这本书的经典性无需多言 ...

  2. vue地址插件多级联动自适应 + github地址

    https://github.com/cqzyl/vue-manyAddress

  3. mysql-作业

    一.表关系 请创建如下表,并创建相关约束                 班级表:class       学生表:student       cid caption grade_id   sid sn ...

  4. CF1174D Ehab and the Expected XOR Problem

    思路: 使用前缀和技巧进行问题转化:原数组的任意子串的异或值不能等于0或x,可以转化成前缀异或数组的任意两个元素的异或值不能等于0或x. 实现: #include <bits/stdc++.h& ...

  5. H5如何做手机app(移动Web App)?图片轮播?ionic、MUI

    移动Web App 跨平台开发 用户不需要去卖场来下载安装App 任何时候都可以发布App只需要一个开发项目 可以使用HTML5,CSS3以及JavaScript以及服务器端语言来完成(PHP,Rub ...

  6. 跨平台移动开发phonegap/cordova 3.3全系列教程-结合asp.net/jqmboile

    遠程app配置 把編譯後的www資料夾,復制到遠程地址(目錄結構不要改變), 例如:建議使用app-framework 1.加入jquery mobile1.4点击打开链接 2.加入app-frame ...

  7. 一、基于Qt的图像矩形区域改色

    Qt环境下图像的打开和涂色 一.设计目标 能够在 Qt QtCreator 环境下打开常用图像格式文件,诸如 bmp.jpg.png 图像等,然后将他们转化为 Qt 中的 QImage 类,并进行矩形 ...

  8. pg中的非varchar类型的模糊搜索

    模糊搜索,bay字段是 numeric 类型的(如果是 varchar 类型的用常规的即可) 1,SELECT * FROM s_view_monitor_result WHERE bay ~~ CA ...

  9. 如何在InstallShield的MSI工程中调用Merge Module的Custom Action

    使用InstallShield创建了合并模块安装程序,定义自定义活动,可如何调用却不太清楚,网上也就找到这点信息,还是没有成功,到底该在什么地方执行合并模块的自定义活动? http://1662487 ...

  10. pat甲级1020中序后序求层序

    1020 Tree Traversals (25)(25 分) Suppose that all the keys in a binary tree are distinct positive int ...