链接:

https://vjudge.net/problem/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 birthday? Surprisingly the result is more than 0.5. Now here you have to do the opposite. You have given the number of days in a year. Remember that you can be in a different planet, for example, in Mars, a year is 669 days long. You have to find the minimum number of people you have to invite in a party such that the probability of at least two people in the party have same birthday is at least 0.5.

思路:

考虑至少两个人生日同一天(Pa) = 1-所有人生日不同(Pb)

即当(Pb)<=0.5时满足条件.Pb = 1(n-1)/n(n-2)/n...

代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
//#include <memory.h>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <math.h>
#include <stack>
#include <string>
#include <assert.h>
#include <iomanip>
#define MINF 0x3f3f3f3f
using namespace std;
typedef long long LL; int n; int main()
{
int t, cnt = 0;
scanf("%d", &t);
while (t--)
{
scanf("%d", &n);
double p = 1;
int sum = n;
int res = 0;
while (p > 0.5)
{
sum--;
p = p*sum/n;
res++;
}
printf("Case %d: %d\n", ++cnt, res);
} return 0;
}

LightOJ-1104-birthday Paradox(概率)的更多相关文章

  1. LightOJ - 1104 Birthday Paradox —— 概率

    题目链接:https://vjudge.net/problem/LightOJ-1104 1104 - Birthday Paradox    PDF (English) Statistics For ...

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

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1104 题意:一年365天,在有23个人的情况下,这23个人中有两个人生日相同的概率是大 ...

  3. lightoj 1104 Birthday Paradox

    题意:给定一个一年的天数,求最少多少人可以使至少两人生日同一天的概率不少于0.5. 用二分去做.检验一个数是否符合时,刚开始实用普通的方法,直接计算,超时了~~,上网搜了一下代码,一位大神使用一个数组 ...

  4. light oj 1104 Birthday Paradox (概率题)

    Sometimes some mathematical results are hard to believe. One of the common problems is the birthday ...

  5. LightOJ - 1104 概率

    题意:每年n天,求最少几个人使这些人中最少两个人生日相同的概率大于0.5 题解:直接递推,假设有k个人,所有情况为n^k,没有相同的情况为n*(n-1)*...*(n-k+1),可以算出1e5以内不超 ...

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

    题目链接:LightOJ - 1030 Description You are in a cave, a long cave! The cave can be represented by a \(1 ...

  7. codeforces 711E. ZS and The Birthday Paradox 概率

    已知一年365天找23个人有2个人在同一天生日的概率 > 50% 给出n,k ,表示现在一年有2^n天,找k个人,有2个人在同一天生日的概率,求出来的概率是a/b形式,化到最简形式,由于a,b可 ...

  8. LightOJ 1104

    题意: 给你一年有n天,求至少有m人使得至少有两个人在同一天生日的概率不少于0.5. 分析: 任意两个人不在同一天生日的概率为C(n,m)*m!/n^m,它的对立事件A为至少有两个人在同一天生日, 则 ...

  9. LightOJ 1248 Dice (III) 概率

    Description Given a dice with n sides, you have to find the expected number of times you have to thr ...

  10. LightOJ 1030 - Discovering Gold - [概率DP]

    题目链接:https://cn.vjudge.net/problem/LightOJ-1030 You are in a cave, a long cave! The cave can be repr ...

随机推荐

  1. Cisco 三层交换机划分VLan与普通路由器连接配置

    根据一些中小企业的一些业务需求,设计一套方案: 计划目标:针对不同部门划分不同的VLAN,前期满足能够同时上网的需求,后期需要能够隔离不同部门的资源访问(本次配置操作不涉及). 因之前未接触CISCO ...

  2. 第三周课程总结&实验报告一

    实验一 Java开发环境与简单Java程序 一.实验目的 熟悉JDK开发环境 熟练掌握结构化程序设计方法 二.实验内容 1.在此处输入标题打印输出所有的"水仙花数",所谓" ...

  3. 课程计划安排 ver: 2016-12-14

    录的越多,后续肯定会涨价. <x86 从实模式到保护模式> 这本书涉及到除了汇编语言,还有一些计算机架构和操作系统方面相关的知识点. 不仅为学习高级编程语言打下了非常扎实的基础,学完C++ ...

  4. [BZOJ 1563] [NOI 2009] 诗人小G(决策单调性)

    [BZOJ 1563] [NOI 2009] 诗人小G(决策单调性) 题面 一首诗包含了若干个句子,对于一些连续的短句,可以将它们用空格隔开并放在一行中,注意一行中可以放的句子数目是没有限制的.小 G ...

  5. golang 组装返回json数据,提供api接口

    model里 package model type Setting struct { Key string `gorm:"primary_key" json:"key&q ...

  6. 04: gitlab安装与使用

    1.1 gitlab安装(192.168.56.12中安装) 1.GitLab是什么? 1. GitLab实现一个自托管的Git项目仓库,可通过Web界面进行访问公开的或者私人项目. 2. GitLa ...

  7. 求问:numpy里面索引时,采用整型数组和整型列表的区别!

  8. python网络爬虫(9)构建基础爬虫思路

    目的意义 基础爬虫分5个模块,使用多个文件相互配合,实现一个相对完善的数据爬取方案,便于以后更完善的爬虫做准备. 这里目的是爬取200条百度百科信息,并生成一个html文件,存储爬取的站点,词条,解释 ...

  9. F12 开发人员工具中的控制台错误消息

    使用此参考解释显示在 Internet Explorer 11 的控制台 和调试程序中的错误消息. 简介 使用 F12 开发人员工具进行调试时,错误消息(例如 EC7111 或 HTML1114)将显 ...

  10. 基于CentOS系统部署EPICS环境

    1.虚拟机安装CentOS系统2.打开终端,以root账户登录3.进入/usr/local目录下,新建文件夹epics,并进入该文件夹4.在/usr/local/epics目录下,执行wget htt ...