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

  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
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <algorithm>
  5. #include <math.h>
  6. #include <map>
  7. #include <queue>
  8. #include <sstream>
  9. #include <iostream>
  10. using namespace std;
  11. #define INF 0x3fffffff
  12.  
  13. int main()
  14. {
  15. //freopen("//home//chen//Desktop//ACM//in.text","r",stdin);
  16. //freopen("//home//chen//Desktop//ACM//out.text","w",stdout);
  17. int T;
  18. scanf("%d",&T);
  19. while(T--)
  20. {
  21. int n;
  22. double l;
  23. scanf("%d%lf",&n,&l);
  24. double sum=;
  25. for(int k=;k<=n;k++)
  26. {
  27. double tmp;
  28. tmp=exp(-l);
  29. for(int i=k;i>=;i--)
  30. {
  31. tmp=tmp*l;
  32. tmp=tmp/i;
  33. }
  34. sum+=tmp;
  35. }
  36. printf("%.3lf\n",sum);
  37. }
  38. return ;
  39. }

zoj3696(泊松分布)的更多相关文章

  1. Poisson泊松分布

    PMF 若随机变量\(K\)的概率质量函数PMF为 \[ P(K = k) = e^ {-\lambda} \frac {\lambda^k}{k!} \] 则称:\(K \sim Poisson(\ ...

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

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

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

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

  4. 各类分布----二项分布,泊松分布,负二项分布,gamma 分布,高斯分布,学生分布,Z分布

    伯努利实验: 如果无穷随机变量序列  是独立同分布(i.i.d.)的,而且每个随机变量  都服从参数为p的伯努利分布,那么随机变量  就形成参数为p的一系列伯努利试验.同样,如果n个随机变量  独立同 ...

  5. 概率论中常见分布总结以及python的scipy库使用:两点分布、二项分布、几何分布、泊松分布、均匀分布、指数分布、正态分布

    概率分布有两种类型:离散(discrete)概率分布和连续(continuous)概率分布. 离散概率分布也称为概率质量函数(probability mass function).离散概率分布的例子有 ...

  6. zoj3696Alien's Organ (二项分布,泊松分布求近似值)

    /*二项分布即重复n次的伯努利试验,每次发生的概率一样,假设成功的概率是p,那么失败的概率就是1-p: 二项分布的概率公式:试验中发生K次的概率是 P(ξ=K)= C(n,k) * p^k * (1- ...

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

  8. 泊松分布 & 指数分布

    一.泊松分布 日常生活中,大量事件是有固定频率的. 某医院平均每小时出生3个婴儿 某公司平均每10分钟接到1个电话 某超市平均每天销售4包xx牌奶粉 某网站平均每分钟有2次访问 它们的特点就是,我们可 ...

  9. Java中利用Math.random()产生服从泊松分布的随机数

    众所周知.Java的Math.random()产生的是服从均匀分布的随机数,可是其它分布的应用也相当广泛,比如泊松分布和高斯分布(正态分布).而这些分布Java没有非常好的提供(高斯分布能够利用Ran ...

随机推荐

  1. 解决C# WINFORM程序只允许运行一个实例的几种方法详解

    要实现程序的互斥,通常有下面几种方式,下面用 C# 语言来实现: 方法一: 使用线程互斥变量. 通过定义互斥变量来判断是否已运行实例. 把program.cs文件里的Main()函数改为如下代码: u ...

  2. mysql常见数据提示 mysql报错提示大全

    错误代码和消息 目录 B.1. 服务器错误代码和消息 B.2. 客户端错误代码和消息 本章列出了当你用任何主机语言调用MySQL时可能出现的错误.首先列出了服务器错误消息.其次列出了客户端程序消息. ...

  3. Javascript Event事件-总结

    一.事件类型 例如:mouseover鼠标移动到.keydown键盘按下 二.事件目标 是发生的事件或与之相关的对象,window.document和Element对象是最常见的事件目标 三.事件对象 ...

  4. Maven的个性化定制

    用Maven的小伙伴都知道,Maven的宗旨是约定优于配置(Convention Over Configuration). 在宗旨的前提下Maven也提供了个性化定制的Profile,让我们看看使用方 ...

  5. python实现dict版图遍历

    python实现dict版图遍历的示例. 代码: #_*_coding:utf_8_import sysimport osclass Graph(): def __init__(self, V, E) ...

  6. iOS7 Xcode 5如何设置隐藏状态栏

    转自:http://www.cocoachina.com/ask/questions/show/99658 最简单直接的方法: 直接在RootViewController.mm里面(Cocos2d-x ...

  7. redis储存中文,客服端读取出现乱码

    [root@cache03 ~]# redis-cli -h 192.168.1.112 -p 6379 192.168.1.112:6379> set chen 陈林 OK 192.168.1 ...

  8. IOS7 隐藏状态栏 (电池栏)

    电池状态栏. //方法一(代码设置): 现在ios7已经更改为透明,并且不占用屏幕高度.其中隐藏及显示的方法如下: 在uiviewcontroller的子类下,调用:     if ([self re ...

  9. 使用Crypto++库的CBC模式实现加密(二)

    前面已经有一篇介绍使用Crypto++库实现的加密的文章了,但是代码中考虑的不完全,所以就重新发了个二 C++封装: #include "zyaes.h" #include < ...

  10. VisualStudio“在查找预编译头使用时跳过"解决方案

    解决方案1:确保所有的cpp文件都包含了stdafx.h,且确保stdafx.h是第一个#include指令(经尝试,可行) 解决方案2:去掉预编译头 项目->属性->配置属性->c ...