zoj 3696 Alien's Organ(泊松分布)
2014-11-17 09:07
627 查看
题目链接: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?
≤ 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.
题意:一个外星人随机产生器官,一天产生的数量的期望是x,求一天内产生个数小于等于N的概率。
分析:泊松分布的概率分布函数为:
泊松分布的参数λ是单位时间(或单位面积)内随机事件的平均发生率。 泊松分布适合于描述单位时间内随机事件发生的次数。
泊松分布的期望和方差均为λ。
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(泊松分布)
- ZOJ 3696 Alien's Organ(泊松分布)
- ZOJ 3696 Alien's Organ
- ZOJ 3696 Alien's Organ / 泊松分布
- zoj 3696 Alien's Organ
- <模板>zoj3696 Alien's Organ 概率论:泊松分布
- zoj 3696 Alien's Organ (泊松分布(概率))
- ZOJ 3696 Alien's Organ 泊松分布
- zoj 3696 Alien's Organ 概率,泊松分布
- ZOJ 3380 Patchouli's Spell Cards(DP,大数)
- ZOJ 3726 Alice's Print Service(RMQ)
- ZOJ 2156 Charlie's Change 多重背包(带路径)
- ZOJ 3569 Dr. Zomboss's Revenge(贪心)
- ZOJ 2186 Keep on Truckin'
- ZOJ 3758 Singles' Day
- zoj 2475 Benny's Compiler
- ZOJ Problem Set - 2186 Keep on Truckin'【模拟】
- ZOJ 3562 Alice's Sequence I
- zoj 2109 FatMouse' Trade (纯水背包问题~贪心❤)
- ZOJ 3804 YY's Minions(简单模拟)