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

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

#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&#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. 【翻译】我钟爱的Visual Studio前端开发工具/扩展

    原文:[翻译]我钟爱的Visual Studio前端开发工具/扩展 怎么样让Visual Studio更好地编写HTML5, CSS3, JavaScript, jQuery,换句话说就是如何更好地做 ...

  2. HttpAsyncClient 做并发长连接的一个实例

    HttpAsyncClient 做并发长连接的一个实例 import java.util.concurrent.CountDownLatch; import org.apache.http.HttpR ...

  3. 《javascript高级编程》读书笔记(三)变量、范围和内存的问题

     第四章:变量.范围和内存的问题 检測类型:typeof是确定一个变量是字符串.数值.布尔值,还是undefined的最佳工具.可是假设变量的值是一个对象或null,typeof仅仅会返回" ...

  4. Asp.Net2.0下C#环境 Login控件实现用户登录

    原文:Asp.Net2.0下C#环境 Login控件实现用户登录 一.前台显示效果 二.前台代码             <asp:Login ID="Login1" run ...

  5. 使用zTree和json构建简单树节点

    我们经常碰到须要构建树结构展示的情况,我推荐使用zTree和JSON. 比如: <? php /** * * 使用zTree和json构建树节点 * */ $arr = array( 0=> ...

  6. ZOJ 3795 Grouping 求最长链序列露点拓扑

    意甲冠军:特定n积分.m向边条. 该点被划分成多个集合随机的每个集合,使得2问题的关键是无法访问(集合只能容纳一个点) 问至少需要被分成几个集合. 假设没有戒指,接着这个话题正在寻求产业链最长的一个有 ...

  7. jquery动态加入删除一行数据

    <html> <head> <title>加入.删除一行</title> <meta http-equiv="content-type& ...

  8. LeetCode18:4Sum

    Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = tar ...

  9. C++ Primer 学习笔记_57_类和数据抽象 --管理指针成员

    复印控制 --管理指针成员 引言: 包括指针的类须要特别注意复制控制.原因是复制指针时.一个带指针成员的指针类 class HasPtr { public: HasPtr(int *p,int i): ...

  10. POJ 1146:ID Codes

    ID Codes Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 6281 Accepted: 3769 Description ...