Description
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 are669 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 contains an integer n (1≤n≤105) in a single line, denoting the number of days in a year in the plan Et.
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
Test instructions
Assuming that there are N days in a year, you need to find your friend to join the party, and ask for at least two people who have the same probability of being equal to 0.5 of the minimum number, this is the minimum number you want to invite.
It's violence. An invitation to calculate the probability
Too much water, nothing to say ~ ~ ~
#include <iostream>using namespacestd;intMain () {intt,i,k=1;cin>>T; Doublep, N; while(t--) {i=0;p =1; CIN>>N; while(p>0.5) {i++; P*= (n-i)/N; } cout<<" Case"<<k++<<": "<<i<<Endl; }return 0;}View Code
Lightoj 1104 Birthday Paradox