LightOJ1104---Birthday Paradox (概率)
来源:互联网 发布:c语言中指针有什么用 编辑:程序博客网 时间:2024/06/09 18:55
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
Output for Sample Input
2
365
669
Case 1: 22
Case 2: 30
Problem Setter: Jane Alam Jan
暴力算了下大概100000的时候要370多个人,鉴于人很少所以直接暴力算就行了
/************************************************************************* > File Name: e.cpp > Author: ALex > Mail: zchao1995@gmail.com > Created Time: 2015年04月30日 星期四 16时03分38秒 ************************************************************************/#include <functional>#include <algorithm>#include <iostream>#include <fstream>#include <cstring>#include <cstdio>#include <cmath>#include <cstdlib>#include <queue>#include <stack>#include <map>#include <bitset>#include <set>#include <vector>using namespace std;const double pi = acos(-1.0);const int inf = 0x3f3f3f3f;const double eps = 1e-15;typedef long long LL;typedef pair <int, int> PLL;int main() { int t; int icase = 1; scanf("%d", &t); while (t--) { int n; double p; scanf("%d", &n); for (int i = 1; i <= 400; ++i) { p = 1; int cnt = n; for (int j = 1; j <= i; ++j) { p *= (cnt * 1.0 / n); --cnt; } if (p <= 0.5) { printf("Case %d: %d\n", icase++, i - 1); break; } } } return 0;}
- LightOJ1104---Birthday Paradox (概率)
- LightOJ1104---Birthday Paradox (概率)
- LightOJ1104---Birthday Paradox (概率)
- LightOJ1104---Birthday Paradox
- LightOJ1104-Birthday Paradox
- LightOJ1104---Birthday Paradox(生日悖论(概率))
- LightOJ1104 birthday parado(经典概率)
- 【数学】LightOJ1104 birthday parado(经典概率)
- LightOJ 1104 - Birthday Paradox【概率】
- [概率+水] light oj 1104 Birthday Paradox
- lightoj-1104-Birthday Paradox【概率】(思维)
- LightOJ 1104 Birthday Paradox (离散概率)
- LightOJ 1104 Birthday Paradox【数学概率】
- 【LightOJ 1104】Birthday Paradox(概率DP)
- lightoj 1104 Birthday Paradox 概率期望
- birthday paradox
- Birthday Paradox
- Birthday Paradox
- telnet www.baidu.com 80后怎么退出到Windows的cmd中来呢?
- nyoj题目53:不高兴的小明
- 机器学习--朴素贝叶斯算法案例
- poj 动态规划DP - 1664 放苹果
- C++ 字符串长度问题
- LightOJ1104---Birthday Paradox (概率)
- android 页面弹出框之Dialog
- YTU ---1402-Greedy Gift Givers 贪婪的送礼者
- Hibernate注解使用以及Spring整合
- 方法重写
- 超大型LED显示屏
- 新浪微博开发之十六(封装网络工具)
- Error spawning cl.exe
- Discuz 出现Access Denied错误提示的原因及解决方法