zoj3696(泊松分布)
p(k)=(y^k) / (k!) * e^(-y)
其中的y就是平均值
k就是我们要求的大小。
Alien's Organ
Time Limit: 2 Seconds Memory Limit: 65536 KB
There's an alien whose name is Marjar. It is an universal solder came from planet Highrich a long time ago.
Marjar is a strange alien. It needs to generate new organs(body parts) to fight. The generated organs will provide power to Marjar and then it will disappear. To fight for problem of moral integrity decay on our earth, it will randomly generate new fighting organs all the time, no matter day or night, no matter rain or shine. Averagely, it will generate λ new fighting organs every day.
Marjar's fighting story is well known to people on earth. So can you help to calculate the possibility of that Marjar generates no more than N organs in one day?
Input
The first line contains a single integer T (0 ≤ T ≤ 10000), indicating there are T cases in total. Then the following T lines each contains one integer N (1 ≤ N ≤ 100) and one float number λ (1 ≤ λ ≤ 100), which are described in problem statement.
Output
For each case, output the possibility described in problem statement, rounded to 3 decimal points.
Sample Input
3
5 8.000
8 5.000
2 4.910
Sample Output
0.191
0.932
0.132
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <sstream>
#include <iostream>
using namespace std;
#define INF 0x3fffffff int main()
{
//freopen("//home//chen//Desktop//ACM//in.text","r",stdin);
//freopen("//home//chen//Desktop//ACM//out.text","w",stdout);
int T;
scanf("%d",&T);
while(T--)
{
int n;
double l;
scanf("%d%lf",&n,&l);
double sum=;
for(int k=;k<=n;k++)
{
double tmp;
tmp=exp(-l);
for(int i=k;i>=;i--)
{
tmp=tmp*l;
tmp=tmp/i;
}
sum+=tmp;
}
printf("%.3lf\n",sum);
}
return ;
}
zoj3696(泊松分布)的更多相关文章
- Poisson泊松分布
PMF 若随机变量\(K\)的概率质量函数PMF为 \[ P(K = k) = e^ {-\lambda} \frac {\lambda^k}{k!} \] 则称:\(K \sim Poisson(\ ...
- zoj 3696 Alien's Organ(泊松分布)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3696 Alien's Organ Time Limit: 2 S ...
- ZOJ 3696 Alien's Organ 概率论 泊松分布
看了好久的题,但还是看得一脸蒙圈,感觉完全无从下手,我的队友告诉我可能是正太分布之类的,但我感觉不太像,后来才听同学说是泊松分布,才恍然大悟,概率论刚刚学过这里不久,不禁感叹,学会了还要会用啊... ...
- 各类分布----二项分布,泊松分布,负二项分布,gamma 分布,高斯分布,学生分布,Z分布
伯努利实验: 如果无穷随机变量序列 是独立同分布(i.i.d.)的,而且每个随机变量 都服从参数为p的伯努利分布,那么随机变量 就形成参数为p的一系列伯努利试验.同样,如果n个随机变量 独立同 ...
- 概率论中常见分布总结以及python的scipy库使用:两点分布、二项分布、几何分布、泊松分布、均匀分布、指数分布、正态分布
概率分布有两种类型:离散(discrete)概率分布和连续(continuous)概率分布. 离散概率分布也称为概率质量函数(probability mass function).离散概率分布的例子有 ...
- zoj3696Alien's Organ (二项分布,泊松分布求近似值)
/*二项分布即重复n次的伯努利试验,每次发生的概率一样,假设成功的概率是p,那么失败的概率就是1-p: 二项分布的概率公式:试验中发生K次的概率是 P(ξ=K)= C(n,k) * p^k * (1- ...
- ZOJ3696 Alien's Organ 2017-04-06 23:16 51人阅读 评论(0) 收藏
Alien's Organ Time Limit: 2 Seconds Memory Limit: 65536 KB There's an alien whose name is Marja ...
- 泊松分布 & 指数分布
一.泊松分布 日常生活中,大量事件是有固定频率的. 某医院平均每小时出生3个婴儿 某公司平均每10分钟接到1个电话 某超市平均每天销售4包xx牌奶粉 某网站平均每分钟有2次访问 它们的特点就是,我们可 ...
- Java中利用Math.random()产生服从泊松分布的随机数
众所周知.Java的Math.random()产生的是服从均匀分布的随机数,可是其它分布的应用也相当广泛,比如泊松分布和高斯分布(正态分布).而这些分布Java没有非常好的提供(高斯分布能够利用Ran ...
随机推荐
- 如何修改浏览器默认的alert样式?
window.alert = function(str) { var shield = document.createElement("DIV"); shield.id = &qu ...
- Mybatis自动生成的配置实例
一.目录 按照图片准备下面的东西吧,基础jar,数据链接库的jar. 二.generatorConfig.xml <?xml version="1.0" encoding=& ...
- Java中path,-classpath,-Djava.library.path的功能和区别
1. path path是个系统环境变量,声明命令的搜索路径,让操作系统找到指定的工具程序. D:\Program Files\Java\jdk1.8.0_111\bin指定JDK工具路径,例如jav ...
- 02、Unicode 汉字转码小工具
在做 Windows app 的时候,与服务器端交互使用的是 json 格式的数据,里面的汉字内容被 编码成 unicode 格式,在调试的时候不太方便,就写了个工具,把里面的 unicode 内容转 ...
- 算法 quick sort
// ------------------------------------------------------------------------------------------------- ...
- 在linux 列出 超级用户 普通用户和 系统用户
#!/bin/bash echo Please select which list you want to print echo "1. admin (enter 1)" echo ...
- Hadoop源码分析之Configuration
转自:http://www.it165.net/admin/html/201312/2178.html org.apache.hadoop.conf.Configuration类是Hadoop所有功能 ...
- gcc参数PIE和PIC的区别和共同点
gcc参数的PIE和PIC 区别 PIE:用在可执行文件 PIC:用在库文件 共同点 生成跟位置没有关系的symbol
- ThinkPHP项目笔记之RBAC(权限相关视频讲解篇
感谢互联网,只要你愿意找,没有找不到的免费资源 网址:http://www.studyfox.cn/143.html
- python中paramiko的安装
windows下安装并使用Python的SSH模块(paramiko+pycrypto+ecdsa) 2014-01-20 14:59 2223人阅读 评论(0) 收藏 举报 python+opens ...