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

题意:一个外星人随机产生器官,一天产生的数量的期望是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's Organ(泊松分布)

时间: 2024-12-30 03:00:32

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

ZOJ 3696 Alien&#39;s Organ 概率论 泊松分布

看了好久的题,但还是看得一脸蒙圈,感觉完全无从下手,我的队友告诉我可能是正太分布之类的,但我感觉不太像,后来才听同学说是泊松分布,才恍然大悟,概率论刚刚学过这里不久,不禁感叹,学会了还要会用啊... 泊松分布的概率函数为: 泊松分布的参数λ是单位时间(或单位面积)内随机事件的平均发生率. 泊松分布适合于描述单位时间内随机事件发生的次数,与题目描述相应和,单位时间就是天, λ 是一天内随机事件的平均发生率.求<=n的概率,做一次求和就好了. #include<iostream> #incl

zoj 3696 Alien&#39;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

ZOJ 3696 Alien&#39;s Organ(泊松定理,期望值)

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 figh

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

题目链接: HDU:http://acm.hdu.edu.cn/showproblem.php?pid=4791 ZJU:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5072 Problem Description Alice is providing print service, while the pricing doesn't seem to be reasonable, so people using her pr

zoj 1100 - Mondriaan&amp;#39;s Dream

题目:在m*n的地板上铺上同样的1*2的地板砖,问有多少种铺法. 分析:dp,组合,计数.经典dp问题,状态压缩. 状态:设f(i,j)为前i-1行铺满,第i行铺的状态的位表示为j时的铺砖种类数: 转移:由于仅仅能横铺或者竖铺.那么一个砖块铺之前的状态仅仅有两种: 且假设当前竖放会对下一行产生影响,建立相邻两行状态相应关系. 这里利用dfs找到全部f(i.j)的上一行的全部前置状态f(i-1,k)加和就可以. f(i.j)= sum(f(i-1,k)){ 当中,f(i-1,k)能够产生f(i.j

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

链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1109 FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean. The warehouse has N rooms. The i-th room contains J

2015省赛小感想

上个月26号,我有幸参加了今年的浙江省省赛.第一次参加正式的ACM比赛,心里略有点小激动.我的队友们也是第一次参加,还好同行的还有学长学姐们的队伍. 早上是热身赛,共四道题,第一题很简单,马上就A掉了.但第二题是到概率题( 第二天得知该题是ZOJ 3696 ),而且好像还是概率论中关于什么分布的.然后队友又看了第三第四题,把题意告诉我后,我也一时不知道怎么做.看着已经有队伍已经A出了第二题,甚至第三第四题也有了,我的心态一下子不好了!!! 我记不清当时到底具体在想什么,只知道当时的我心态已经乱了

=-098765

http://ypk.39.net/search/all?k=%A1%B8%D4%E6%D1%F4%C3%D4%BB%C3%D2%A9%D4%F5%C3%B4%B9%BA%C2%F2Q%A3%BA%A3%B6%A3%B9%A3%B5%A3%B2%A3%B5%A3%B6%A3%B7%A3%B1%A3%B7%A8%7C http://ypk.39.net/search/all?k=%A8%93%D2%CB%B3%C7%C3%D4%BB%C3%D2%A9%D4%F5%C3%B4%B9%BA%C2%F2

ZOJ 3674 模拟

[题意]:若干组数据 每组给一个整数n代表n个名词(单词),接下来1-n给出一个单词和一行注释(一行注释由多个字符串组成),然后给出一个整数m,接下来1-m 每行若干个单词来自(1-n),要求出这若干个单词共有的注释字符串并按字典序排列输出,若不存在则输出NO. Sample Input 4 fish agile animal horse swift animal eagle fierce animal Kyuubee alien incubator 2 fish horse eagle fis