集训第六周 数学概念与方法 概率 F题
Description
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
每个人都有自己的生日,如果一群人站在一起,那么他们有至少两个人生日相同的概率是多少? 例如有任意22个人站在一起,概率就能达到0.5
所以问你给出一年的时间长(不一定是365天,有可能是火星来的),需要选出至少多少人才能使概率不低于0.5
方法:选N个人,这一群人生日都不相同的概率是P=364/365+363/365+362/365.........
最后使得P小于等于0.5就行了
#include"iostream"
#include"cstdio"
using namespace std;
int main()
{
int T,ca=;
cin>>T;
while(T--)
{
int year,sel;
cin>>year;
sel=year;
int ans=;
double p=1.0;
while(p>0.5)
{
ans++;
sel--;
p*=(sel*1.0)/year;
}
printf("Case %d: %d\n",ca++,ans);
}
return ;
}
O(O_O)O
集训第六周 数学概念与方法 概率 F题的更多相关文章
- 集训第六周 数学概念与方法 概率 N题
N - 概率 Time Limit:4000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit Status ...
- 集训第六周 数学概念与方法 概率 数论 最大公约数 G题
Description There is a hill with n holes around. The holes are signed from 0 to n-1. A rabbit must h ...
- 集训第六周 数学概念与方法 数论 筛素数 H题
Description 小明对数的研究比较热爱,一谈到数,脑子里就涌现出好多数的问题,今天,小明想考考你对素数的认识. 问题是这样的:一个十进制数,如果是素数,而且它的各位数字和也是素数,则称之为“ ...
- 集训第六周 数学概念与方法 计数 排列 L题
Description 大家常常感慨,要做好一件事情真的不容易,确实,失败比成功容易多了! 做好“一件”事情尚且不易,若想永远成功而总从不失败,那更是难上加难了,就像花钱总是比挣钱容易的道理一样. 话 ...
- 集训第六周 数学概念与方法 J题 数论,质因数分解
Description Tomorrow is contest day, Are you all ready? We have been training for 45 days, and all g ...
- 集训第六周 数学概念与方法 数论 线性方程 I题
Description The Sky is Sprite. The Birds is Fly in the Sky. The Wind is Wonderful. Blew Throw the Tr ...
- 集训第六周 数学概念与方法 UVA 11181 条件概率
http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18546 题意:有n个人会去超市,其中只有r个人会买东西,每个人独自买东西的概 ...
- 集训第六周 数学概念与方法 UVA 11722 几何概型
---恢复内容开始--- http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=31471 题意,两辆火车,分别会在[t1,t2],[ ...
- 集训第六周 古典概型 期望 D题 Discovering Gold 期望
Description You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell o ...
随机推荐
- (DP)51NOD 1183 编辑距离
编辑距离,又称Levenshtein距离(也叫做Edit Distance),是指两个字串之间,由一个转成另一个所需的最少编辑操作次数.许可的编辑操作包括将一个字符替换成另一个字符,插入一个字符,删除 ...
- Luogu P1991 无线通讯网 【最小生成树】
题目描述 国防部计划用无线网络连接若干个边防哨所.2 种不同的通讯技术用来搭建无线网络: 每个边防哨所都要配备无线电收发器:有一些哨所还可以增配卫星电话. 任意两个配备了一条卫星电话线路的哨所(两边都 ...
- 【原创】《从0开始学RocketMQ》—集群搭建
用两台服务器,搭建出一个双master双slave.无单点故障的高可用 RocketMQ 集群.此处假设两台服务器的物理 IP 分别为:192.168.50.1.192.168.50.2. 内容目录 ...
- CocoaPods 升级出现问题 (一)
升级了cocoapods 然后出现了这个问题 , 一上午时间各种FQ啊 ,终于吃完饭后找到原因了 ,OK 开工
- Windows下安装Ubuntu16.04双系统
ROS需要在Ubuntu系统上开发,虚拟机跑Ubuntu开发ROS容易出现各种各样的问题,所以需要安装Ubuntu16.04双系统.笔者也是一步步按着网上的帖子来,由于网上的教程都不是最新的而且有的也 ...
- [BZOJ2056]gift? 高精度?
Description Input 输入的第一行为一个整数t. 接下来t行,每行包含九个自然数. Output 输出t行 每行一个整数,表示\(2^a+2^b+2^c+2^d+2^e+2^f+2^g+ ...
- 比较C#中几种常见的复制字节数组方法的效率[转]
[原文链接] 在日常编程过程中,我们可能经常需要Copy各种数组,一般来说有以下几种常见的方法:Array.Copy,IList<T>.Copy,BinaryReader.ReadByte ...
- 增大PHP允许上传的文件大小;解决POST Content-Length exceeds the limit
在php.ini中: upload_max_filesize = 1000M ;1GB post_max_size = 1000M 然后重启apache 参考链接
- SpringBoot 2.x (3):文件上传
文件上传有两个要点 一是如何高效地上传:使用MultipartFile替代FileOutputSteam 二是上传文件的路径问题的解决:使用路径映射 文件路径通常不在classpath,而是本地的一个 ...
- CCF|跳一跳
import java.util.Scanner; public class Main { public static void main (String[] args) { Scanner scan ...