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. LR C语言语句复习,几个简单代码

    嵌套循环 Action() { int i,j; ;i<=;i++) { ) beark; else lr_output_message("i=%d",i); ;j<= ...

  2. Java并发包——线程同步和锁

    Java并发包——线程同步和锁 摘要:本文主要学习了Java并发包里有关线程同步的类和锁的一些相关概念. 部分内容来自以下博客: https://www.cnblogs.com/dolphin0520 ...

  3. ubuntu安装robo3t

    直接在官网下载 解压文件(使用命令 tar -zxvf robo3t-1.2.1-linux-x86_64-3e50a65.tar.gz) 打开解压后的文件,进入bin文件,直接在终端运行 ./rob ...

  4. 网页游戏中PK系统的实现

    在游戏开发过程中,写过一个简单的PK系统面板,涉及到前端和后端的交互,我将自己制作的流程分享给大家,大概流程是这样:前端发送PK邀请给后端,后端受到请求后将信息返回给前端处理,先来看下整个流程图及思路 ...

  5. mybat-大文件的存取

    在mybatis中存储大文件可以直接存 取的时候取出来的是二进制 1.在实体类中添加大文本和图片 package com.java1234.model; public class Student { ...

  6. 慎用python的pop和remove方法

    申明:转载请注明出处!!! Python关于删除list中的某个元素,一般有两种方法,pop()和remove(). 如果删除单个元素,使用基本没有什么问题,具体如下. 1.pop()方法,传递的是待 ...

  7. 微软高性能缓存AppFabric(二)使用

    原文链接:http://www.cnblogs.com/Qbit/p/6102614.html 从AppFabric 的安装目录中选择两个dll添加到项目中, 默认安装位置:C:\Program Fi ...

  8. Copy Failed Error Access to fobidden

    使用SVN的branch/tag命令来切包时,报出了一下错误提示 就这个错误,调了整整一天,如果你也遇到了类似问题,我真心希望下面解决问题的过程能帮助到你:D 解决过程: 1.网上查了很多帖子,发现跟 ...

  9. pat甲级1013

    1013 Battle Over Cities (25)(25 分) It is vitally important to have all the cities connected by highw ...

  10. shell 快速浏览

    总结自: https://github.com/qinjx/30min_guides/blob/master/shell.md: http://blog.itpub.net/14293828/view ...