泊松分布。。。。

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

Author: FAN, Yuzhe
Contest: The 13th Zhejiang University Programming Contest

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. double boshon(int x,double r)
  9. {
  10. double ans=exp(-r)*pow(r,x);
  11. for(int i=;i<=x;i++)
  12. {
  13. ans=ans/i;
  14. }
  15. return ans;
  16. }
  17.  
  18. int main()
  19. {
  20. int t;
  21. scanf("%d",&t);
  22. while(t--)
  23. {
  24. int x;
  25. double y;
  26. cin>>x>>y;
  27. double ans=.;
  28. for(int i=;i<=x;i++)
  29. {
  30. ans+=boshon(i,y);
  31. }
  32. printf("%.3lf\n",ans);
  33. }
  34. return ;
  35. }

ZOJ 3696 Alien's Organ的更多相关文章

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

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

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

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

  3. zoj 3696 Alien&#39;s Organ(泊松分布)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3696 Alien's Organ Time Limit: 2 S ...

  4. ****K - Alien's Organ

    K - Alien's Organ Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Sub ...

  5. 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 ...

  6. zoj3696(泊松分布)

    p(k)=(y^k) / (k!) * e^(-y) 其中的y就是平均值 k就是我们要求的大小. Alien's Organ Time Limit: 2 Seconds      Memory Lim ...

  7. ZOJ 1825 compoud words

    题目大意:输入一串递增的单词序列,需要找出符合条件的单词递增输出,条件是:将一个单词拆成左右两个单词后,能在输入中找到这两个单词.例如单词 alien,可以拆成 a 和 lien,而输入中刚好同时有a ...

  8. ZOJ People Counting

    第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ  3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...

  9. [LeetCode] Alien Dictionary 另类字典

    There is a new alien language which uses the latin alphabet. However, the order among letters are un ...

随机推荐

  1. Dan Zhang - Visual Studio ALM MVP

    I am a Microsoft Certified Partner specialising in .NET solutions, also worked as an ALM consultant. ...

  2. IBM云的商务动作之我见(2):IBM 和 VMware 战略合作推进混合云

    本系列文章基于公开信息,对IBM云的近期商务动作比如收购.战略合作.整合等,给出本人的快速分析,仅仅代表本人个人观点,和本人所在的公司和所在的岗位没有任何关系: (1)IBM 收购 Blue Box ...

  3. 【CSS】使用盒模型

    盒子是CSS中的基础概念,我们需要使用它来配置元素的外观以及文档的整体布局. 1. 为元素应用内边距 应用内边距会在元素内容和边距之间添加空白.我们可以为内容盒的每个边界单独设置内边距,或者使用 pa ...

  4. HTML总结

    几个知识点: HTML 指的是超文本标记语言 (Hyper Text Markup Language) HTML框架结构: <!DOCTYPE html> <html> < ...

  5. python高级之函数

    python高级之函数 本节内容 函数的介绍 函数的创建 函数参数及返回值 LEGB作用域 特殊函数 函数式编程 1.函数的介绍 为什么要有函数?因为在平时写代码时,如果没有函数的话,那么将会出现很多 ...

  6. 原生JS实现MVVM模式

    欢迎大家指导与讨论 : ) 前言 关于MVVM的原理大家可以参考这篇文章.<[翻译]Object.observe()带来的数据绑定变革 >http://www.tuicool.com/ar ...

  7. linux tcl expect 安装(转)

    linux tcl expect 安装 一.Tcl安装 1.  下载:tcl8.4.20-src.tar.gz http://www.tcl.tk/software/tcltk/downloadnow ...

  8. jquery easyui 1.4.1 验证时tooltip 的位置调整

    现象是在表单中如果显示两列控件,右边的控件是combo,combobox 等右边有按钮的,宽度为100%时,验证不通过的tooltip 显示位置不准确如下图所示 打开 jquery.easyui-1. ...

  9. CSS实现背景透明,文字不透明(兼容各浏览器)

    在 FF/Chrome 等较新的浏览器中可以使用css属性background- color的rgba轻松实现背景透明,而文字保持不透明.而IE6/7/8浏览器不支持rgba,只有使用IE的专属滤镜f ...

  10. jquery富文本在线编辑器UEditor

    UEditor 是由百度「FEX前端研发团队」开发的所见即所得富文本web编辑器,具有轻量,可定制,注重用户体验等特点,开源基于MIT协议,允许自由使用和修改代码. UEditor的功能非常强大,官方 ...