版权声明:转载请注明出处。 https://blog.csdn.net/u014427196/article/details/46455747

题目链接: http://www.lightoj.com/volume_showproblem.php?problem=1104
题意:生日驳论,求最小满足条件的人数
代码:

#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <ctype.h>
#include <time.h>
#include <queue>
#include <map>
#include <set>

using namespace std;

int t;
int n;
int dp[100010];

int main()
{
    cin >> t;
    for (int ca = 1; ca <= t; ca++)
    {
        memset(dp,0,sizeof(dp));
        cin >> n;
        cout << "Case " << ca << ": ";
        if (n == 1)
            cout << 1 << endl;
        else
        {
            double ans = 1.0;
            int i;
            for ( i = 1; i <= n; i++)
            {
                ans *= ((n - i)*1.0 / n);
                if (ans <= 0.5)
                    break;
            }
            cout << i << endl;
        }
    }
    return 0;
}