题目链接: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

  1. 3
  2. 5 8.000
  3. 8 5.000
  4. 2 4.910

Sample Output

  1. 0.191
  2. 0.932
  3. 0.132

题意:一个外星人随机产生器官,一天产生的数量的期望是x,求一天内产生个数小于等于N的概率。
分析:泊松分布的概率分布函数为: 泊松分布的參数λ是单位时间(或单位面积)内随机事件的平均发生率。 泊松分布适合于描写叙述单位时间内随机事件发生的次数。
 泊松分布的期望和方差均为λ。

  1. #include <cstdio>
  2. #include <cmath>
  3.  
  4. int main()
  5. {
  6. double x;
  7. int T, n;
  8. scanf("%d", &T);
  9. while(T--) {
  10. scanf("%d%lf", &n, &x);
  11. double ans = 0;
  12. double fac = 1;
  13. for(int i = 1; i <= n; i++) {
  14. fac *= (double)i;
  15. ans += pow(x, (double)i) / fac * exp(-x);
  16. }
  17. ans += exp(-x); // P(x=0)的情况
  18. printf("%.3lf\n", ans);
  19. }
  20. return 0;
  21. }

zoj 3696 Alien&#39;s Organ(泊松分布)的更多相关文章

  1. ZOJ 3696 Alien's Organ 概率论 泊松分布

    看了好久的题,但还是看得一脸蒙圈,感觉完全无从下手,我的队友告诉我可能是正太分布之类的,但我感觉不太像,后来才听同学说是泊松分布,才恍然大悟,概率论刚刚学过这里不久,不禁感叹,学会了还要会用啊... ...

  2. ZOJ 3696 Alien's Organ

    泊松分布.... Alien's Organ Time Limit: 2 Seconds      Memory Limit: 65536 KB There's an alien whose name ...

  3. ZOJ 3696 Alien's Organ(泊松定理,期望值)

    Alien's Organ Time Limit: 2 Seconds      Memory Limit: 65536 KB There's an alien whose name is Marja ...

  4. HDU 4430 &amp; ZOJ 3665 Yukari&#39;s Birthday(二分法+枚举)

    主题链接: HDU:pid=4430" target="_blank">http://acm.hdu.edu.cn/showproblem.php?pid=4430 ...

  5. zoj 1738 - Lagrange&#39;s Four-Square Theorem

    称号:四方形定理.输出可以表示为一个数目不超过四个平方和表示的数. 分析:dp,完全背包.背包分割整数.可用一维分数计算,它也可以被写为一个二维团结. 状态:设f(i,j,k)为前i个数字,取j个数字 ...

  6. zoj 2156 - Charlie&#39;s Change

    称号:拼布钱,表面值至1,5.10.25.寻求组成n表面值硬币的最大数目. 分析:dp,01背包.需要二元分割,除此以外TLE.使用每个硬币的数组记录数.轻松升级. 写了一个 多重背包的 O(NV)反 ...

  7. zoj 2402 - Lenny&#39;s Lucky Lotto Lists

    称号:序列,在前面的每个元件的至少两倍,最大值至n.问:长l船舶有许多这样的. 分析:dp,LIS类别似事. 状态:f(i,j)结束数字为j且长度为i的序列的个数.有转移方程: F[ i ][ j ] ...

  8. HDU 4791 &amp; ZOJ 3726 Alice&#39;s Print Service (数学 打表)

    题目链接: HDU:http://acm.hdu.edu.cn/showproblem.php?pid=4791 ZJU:http://acm.zju.edu.cn/onlinejudge/showP ...

  9. ZOJ 2109 FatMouse&#39; Trade (背包 dp + 贪婪)

    链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1109 FatMouse prepared M pounds of cat ...

随机推荐

  1. CSS selectors for Selenium with example,selenium IDE

    CSS selectors for Selenium with example http://seleniumeasy.com/selenium-tutorials/css-selectors-tut ...

  2. 对consistencygroup的一些研究和实践

    声明: 本博客欢迎转载,但请保留原作者信息! 作者:李人可 团队:华为杭州OpenStack团队 consistency group,直译是一致性组,是Juno版本号cinder新引进的一个概念.顾名 ...

  3. java 解析 json 遍历未知key

    1.—————————————————————————————————————————————————————————————— import net.sf.json.JSONObject; Stri ...

  4. Linux系统部署规范v1.0

    Linux系统部署规范v1.0 目的: 1.尽可能减少线上操作: 2.尽可能实现自动化部署: 3.尽可能减少安装服务和启动的服务: 4.尽可能使用安全协议提供服务: 5.尽可能让业务系统单一: 6.尽 ...

  5. CSS3影子 box-shadow使用和技巧总结

    text-shadow阴影效果添加到文本,box-shadow块元素被添加到周围的阴影. 随着html5和CSS3声望.越来越普遍的使用特效. 基本语法这是{box-shadow:[inset] x- ...

  6. J2EE的13个规范之JDBC

    假设让你接触一样新的东西.你可能感觉无所适从,可是假设本来就是旧事物的话,你学习起来还难吗? 一.ODBC,我们的老朋友 ODBC(Open Database Connectivity)是微软公司与数 ...

  7. 大页(huge pages) 三大系列 ---计算大页配置参数

    使用以下shell 脚本来计算大页配置参数,确保使用脚本实例之前的数据已经开始, 如果数据库的版本号11g,确认是否使用自己主动的内存管理(AMM) +++++++++++++++++++++++++ ...

  8. shell手册--笨鸟杰作

    ==================================================================================================== ...

  9. 勾股数组及其应用uva106

    勾股数组 设三元组(a,b,c)满足a^2 + b^2 = c^2的勾股数组,那么是否存在无穷多个勾股数组呢, 答案是肯定的,将三元组乘以d,可以得到新的三元组(da,db,dc) 即(da)^2 + ...

  10. Xamarin 手动安装步骤+破解

    原文:Xamarin 手动安装步骤+破解 由于Xamarin运行的时候有很多依赖项,所以现在在官网上下载的XamarinInstall只是一个下载安装器,并不是软件包.它会自动下载安装所需的依赖软件, ...