Title Link: http://lightoj.com/volume_showproblem.php?problem=1104
Test instructions: 365 days a year, in the case of 23 people, two of these 23 people have the same probability of birthday is greater than 0.5;
Now on different planets for n days a year, to find X, at least x person to make two people in this x of the birthday of the same probability is >=0.5, and now in addition to their own x person, for X;
We press N = 365, then there are x individuals, the probability that these people birthdays are different is P = 1 * 364/365 * 363/365 * 362/365 * ... * (365-x)/365
Then someone's birthday the same probability is 1-p that when X >= 23 (not add themselves) 1-p>0.5, so can find out the situation of p<0.5
#include <cstring>#include<cstdio>#include<iostream>#include<algorithm>#include<cmath>#include<stack>#include<vector>#include<queue>using namespacestd;#defineN 105#defineMet (A, b) memset (A, B, sizeof (a))#defineMOD 110119typedefLong LongLL;intMain () {intN; intT, T =1; scanf ("%d", &T); while(t--) {scanf ("%d", &N); Doublep =1.0; intCNT = n, ans =0; while(P >0.5) { --CNT; P= p*cnt/N; Ans++; } printf ("Case %d:%d\n", t++, ans); } return 0;}
View Code
Lightoj 1104-birthday Paradox (Birthday paradox probability)