Birthday Paradox : Solution
Description Coming Soon..................
#include<bits/stdc++.h>
#define ld double
using namespace std;
int main()
{
int t, k = 1;
cin >> t;
while(t--)
{
ld n, r = 1.0, i = 0.0;
cin >> n;
if(n == 1)
{
cout << "Case " << k++ << ": " << 1 << "\n";
continue;
}
while(r > 0.5)
{
i++;
r *= (n-i)/n;
}
cout << "Case " << k++ << ": " << i << "\n";
}
return 0;
}
Comments
Post a Comment