SGU 495 Kids and Prizes 概率 二项分布
来源:互联网 发布:淘宝卖家扣分 编辑:程序博客网 时间:2024/05/22 12:42
题目大意:
就是想在有N个奖品分别装在N个盒子里,M个人依次选择盒子,每个人选择每个盒子的可能性都是相等的,当一个人选择盒子之后那个盒子里的奖品就被领走,空盒子放回原位,如果选择了空盒子则没有奖品, 盒子依旧放回原位,问最终送出的奖品的份数的期望
大致思路:
首先对于任何一个盒子,其中的礼物在M个人选择之后依旧没有被拿走的概率是(1 - 1/N)^M, 那么被拿走的可能性是(1 - (1 - 1/N)^M), 由于N个盒子中的奖品是否被拿走了事相互独立的, 一共N个盒子,被拿走礼物的盒子的个数X服从二项分布 X~B(N, (1 - (1 - 1/N)^M)), 故E(X) = N*(1 - (1- 1/N)^M)
代码如下:
Result : Accepted Memory : 54 KB Time : 15 ms
/* * Author: Gatevin * Created Time: 2014/12/22 15:38:06 * File Name: Sora_Kasugano.cpp */#include<iostream>#include<sstream>#include<fstream>#include<vector>#include<list>#include<deque>#include<queue>#include<stack>#include<map>#include<set>#include<bitset>#include<algorithm>#include<cstdio>#include<cstdlib>#include<cstring>#include<cctype>#include<cmath>#include<ctime>#include<iomanip>using namespace std;const double eps(1e-8);typedef long long lint;int main(){ int n,m; scanf("%d %d", &n, &m); printf("%.9f", n*(1 - pow(1 - 1.0/n, m))); return 0;}
0 0
- SGU 495 Kids and Prizes 概率 二项分布
- [ACM] SGU 495 Kids and Prizes (概率,期望,二项分布)
- SGU 495 Kids and prizes(概率题,二项分布)
- SGU 495 Kids and Prizes (二项分布)
- SGU 495 Kids and Prizes(概率dp)
- sgu 495 Kids and Prizes 求概率
- Sgu 495 Kids and Prizes (概率dp)
- sgu 495 Kids and Prizes 概率dp
- SGU 495 Kids and Prizes 概率dp
- SGU 495 Kids and Prizes(概率dp)
- SGU 495 Kids and Prizes(概率)
- [概率dp] sgu 495 Kids and Prizes
- Kids and Prizes - SGU 495
- SGU 495 Kids and Prizes
- SGU 495 Kids and Prizes
- SGU 495 Kids and Prizes (概率DP)
- SGU 495 Kids and Prizes (概率DP)
- SGU 495 Kids and Prizes (概率DP入门)
- Nginx学习笔记(一)——入门
- 移植sbull至kernel version > 2.6.31
- Android- 环信IM即时通讯_RESTAPI(2)
- Java内存模型详解
- LeetCode:Majority Element
- SGU 495 Kids and Prizes 概率 二项分布
- 分析Java线程中断机制stop和interrupted的用法
- 多个storyboard 间的跳转
- 第17周项目1体会函数参数传递
- ArcGIS For Flex地图联动
- 记一次nginx崩溃
- ISO C90 forbids mixed declarations and code 警告
- 使用CocoaPods来管理iOS项目的依赖库
- 蓝桥杯测试试题 入门训练 圆的面积