Sometimes some mathematical results is hard to believe. One of the common problems is the birthday paradox. Suppose you is in a party where there is people including you. What's the probability that at least and the party has same birthday? Surprisingly the result is more than 0.5. Now this is the opposite. You are given the number of days in a year. Remember that's you can are in a different planet, for example, in Mars, and a year are 669 days long. You has to find the minimum number of people you has to invite in a party such that the probability of at least B peop The Le in the party has same birthday is at least 0.5.
Input
Input starts with an integer T (≤20000), denoting the number of test cases.
Each case is contains an integer n (1≤n≤105) in a, and 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
It's about 370 people in the 100000, and it's just a little more direct violence.
/************************************************************************* > File name:e.cpp > Author:al ex > Mail: [email protected] > Created time:2015 April 30 Thursday 16:03 38 seconds ************************************** **********************************/#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 DoublePI =ACOs(-1.0);Const intINF =0x3f3f3f3f;Const DoubleEPS =1e-15;typedef Long LongLL;typedefPair <int,int> PLL;intMain () {intTintIcase =1;scanf("%d", &t); while(t--) {intNDoublePscanf("%d", &n); for(inti =1; I <= -; ++i) {p =1;intCNT = n; for(intj =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 (probability)