zoj 3696 Alien's Organ(泊松分布)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3696
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 <cstdio>
#include <cmath> int main()
{
double x;
int T, n;
scanf("%d", &T);
while(T--) {
scanf("%d%lf", &n, &x);
double ans = 0;
double fac = 1;
for(int i = 1; i <= n; i++) {
fac *= (double)i;
ans += pow(x, (double)i) / fac * exp(-x);
}
ans += exp(-x); // P(x=0)的情况
printf("%.3lf\n", ans);
}
return 0;
}
zoj 3696 Alien's Organ(泊松分布)的更多相关文章
- ZOJ 3696 Alien's Organ 概率论 泊松分布
看了好久的题,但还是看得一脸蒙圈,感觉完全无从下手,我的队友告诉我可能是正太分布之类的,但我感觉不太像,后来才听同学说是泊松分布,才恍然大悟,概率论刚刚学过这里不久,不禁感叹,学会了还要会用啊... ...
- ZOJ 3696 Alien's Organ
泊松分布.... Alien's Organ Time Limit: 2 Seconds Memory Limit: 65536 KB There's an alien whose name ...
- ZOJ 3696 Alien's Organ(泊松定理,期望值)
Alien's Organ Time Limit: 2 Seconds Memory Limit: 65536 KB There's an alien whose name is Marja ...
- HDU 4430 & ZOJ 3665 Yukari's Birthday(二分法+枚举)
主题链接: HDU:pid=4430" target="_blank">http://acm.hdu.edu.cn/showproblem.php?pid=4430 ...
- zoj 1738 - Lagrange's Four-Square Theorem
称号:四方形定理.输出可以表示为一个数目不超过四个平方和表示的数. 分析:dp,完全背包.背包分割整数.可用一维分数计算,它也可以被写为一个二维团结. 状态:设f(i,j,k)为前i个数字,取j个数字 ...
- zoj 2156 - Charlie's Change
称号:拼布钱,表面值至1,5.10.25.寻求组成n表面值硬币的最大数目. 分析:dp,01背包.需要二元分割,除此以外TLE.使用每个硬币的数组记录数.轻松升级. 写了一个 多重背包的 O(NV)反 ...
- zoj 2402 - Lenny's Lucky Lotto Lists
称号:序列,在前面的每个元件的至少两倍,最大值至n.问:长l船舶有许多这样的. 分析:dp,LIS类别似事. 状态:f(i,j)结束数字为j且长度为i的序列的个数.有转移方程: F[ i ][ j ] ...
- HDU 4791 & ZOJ 3726 Alice's Print Service (数学 打表)
题目链接: HDU:http://acm.hdu.edu.cn/showproblem.php?pid=4791 ZJU:http://acm.zju.edu.cn/onlinejudge/showP ...
- ZOJ 2109 FatMouse' Trade (背包 dp + 贪婪)
链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1109 FatMouse prepared M pounds of cat ...
随机推荐
- JS数组追加数组採用push.apply的坑
JS数组追加数组没有现成的函数,这么多年我已经习惯了a.push.apply(a, b);这样的自以为非常酷的,不须要写for循环的写法,一直也没遇到什么问题,直到今天我要append的b是个非常大的 ...
- hdu 4961 Boring Sum(数学题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4961 Problem Description Number theory is interesting ...
- Java文件压缩分割(待)
http://blog.csdn.net/ycg01/article/details/1366648
- A Game of Thrones(2) - Catelyn
Catelyn had never liked this godswood(神木林). She had been born a Tully, at Riverrun far to the south, ...
- Java并发编程(您不知道的线程池操作)
Java并发编程(您不知道的线程池操作) 这几篇博客,一直在谈线程,设想一下这个场景,如果并发的线程很多,然而每个线程如果执行的时间很多的话,这样的话,就会大量的降低系统的效率.这时候就可以采用线程池 ...
- WIFI实时监控追踪小车演示视频——安卓端、小车
文章由@超人爱因斯坦出品,转载请注明出处. 文章链接: http://hpw123.net/a/qingsongyike/yingyinqu/2014/1019/59 ...
- intellij idea该插件开发摘要
最近在做一个intellij idea插件,功能是读取表和数据库信息字段和预先定义的模板来生成代码文件(实体,service,springmvc该controller,freemark文件等). 找了 ...
- 参数化测试--sheet表的应用
自动化测试对录制和编辑好的测试步骤进行回放,这种是线性的自动化测试方式,其缺点是明显的,就是其测试覆盖面比较低.测试回放的只是录制时做出的界面操作,以及输入的测试数据,或者是脚本编辑时指定的界面操作和 ...
- uva 1557 - Calendar Game(博弈)
option=com_onlinejudge&Itemid=8&page=show_problem&problem=4332" target="_blank ...
- Makefile 管理工具 — Automake and Autoconf
该project下载路径:http://files.cnblogs.com/iTsihang/hello-2.0.zip automake 參考资料:http://www.linuxforum.net ...