LightOJ1104---Birthday Paradox (在n天中,至少有多少人,才满足有两个人的生日相同的概率要大于50%(概率)

题意:http://www.lightoj.com/volume_showproblem.php?problem=1104

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<vector>
#include<math.h>
#include<string>
using namespace std;
#define INF 0x3f3f3f3f
#define LL long long
#define N 10006
#define Lson rood<<1
#define Rson rood<<1|1
int main()
{
    int T,t=1;
    scanf("%d",&T);
    while(T--)
    {
        int n;
        scanf("%d",&n);
        int ans=0;
        double sum=1.0;
        while(1)
        {
            sum*=1.0*(n-ans)/n;
            if(1-sum>=0.5) break;
            ans++;
        }
        printf("Case %d: %d
",t++,ans);
    }
    return 0;
}
原文地址:https://www.cnblogs.com/a719525932/p/7804103.html