LightOJ 1104 - Birthday Paradox【概率】

题目链接: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;
}
时间: 2024-08-07 14:59:34

LightOJ 1104 - Birthday Paradox【概率】的相关文章

LightOj 1104 - Birthday Paradox(生日悖论概率)

题目链接:http://lightoj.com/volume_showproblem.php?problem=1104 题意:一年365天,在有23个人的情况下,这23个人中有两个人生日相同的概率是大于 0.5 的: 现在在不同的星球上一年有n天,求出x,至少有 x 个人才能使得这 x 人中有两个人的生日相同的概率是>=0.5的:现在除了自己之外还要 x 个人,求x: 我们按 n = 365 算的话,那么有x个人,这些人生日都不相同的概率是 p = 1 * 364/365 * 363/365 *

LightOJ 1104 Birthday Paradox

Description Sometimes some mathematical results are hard to believe. One of the common problems is the birthday paradox. Suppose you are in a party where there are 23 people including you. What is the probability that at least two people in the party

Birthday Paradox lightoj 1104 生日悖论(概率)

Description Sometimes some mathematical results are hard to believe. One of the common problems is the birthday paradox. Suppose you are in a party where there are 23 people including you. What is the probability that at least two people in the party

light oj 1104 Birthday Paradox (概率题)

Sometimes some mathematical results are hard to believe. One of the common problems is the birthday paradox. Suppose you are in a party where there are 23 people including you. What is the probability that at least two people in the party have same b

Birthday Paradox LightOJ - 1104

Sometimes some mathematical results are hard to believe. One of the common problems is the birthday paradox. Suppose you are in a party where there are 23 people including you. What is the probability that at least two people in the party have same b

LightOJ 1030 Discovering Gold (概率/期望DP)

题目链接:LightOJ - 1030 Description You are in a cave, a long cave! The cave can be represented by a \(1 \times N\) grid. Each cell of the cave can contain any amount of gold. Initially you are in position \(1\). Now each turn you throw a perfect \(6\) s

LightOJ1104---Birthday Paradox (概率)

Sometimes some mathematical results are hard to believe. One of the common problems is the birthday paradox. Suppose you are in a party where there are 23 people including you. What is the probability that at least two people in the party have same b

codeforces 711E. ZS and The Birthday Paradox 概率

已知一年365天找23个人有2个人在同一天生日的概率 > 50% 给出n,k ,表示现在一年有2^n天,找k个人,有2个人在同一天生日的概率,求出来的概率是a/b形式,化到最简形式,由于a,b可能非常大,对a,b分别%(10^6+3) 注意,这道题是先化到最简,再分别取模 首先,特判 k > 2^n 时,a = 1,b = 1 没有2个人同一天生日的概率为: 2^n * (2^n - 1) * ... * (2^n - k + 1) / 2^(nk) 所以a,b化简之前分别是: a = 2nk

LightOJ 1104

题意: 给你一年有n天,求至少有m人使得至少有两个人在同一天生日的概率不少于0.5. 分析: 任意两个人不在同一天生日的概率为C(n,m)*m!/n^m,它的对立事件A为至少有两个人在同一天生日,则P(A) = 1 - C(n,m)*m!/n^m = 1 - P(n,m)/n^m(后一个P表示排列); 根据题意有P(A) >= 0.5 即 P(n, m)/n^m <= 0.5. 该式的展开式为 p = n/n*(n-1)/n*(n-2)/n*...*(n-m+1)/n, 因此只要判断该式的累乘