题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3696
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?
3 5 8.000 8 5.000 2 4.910
0.191 0.932 0.132
#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; }
原文地址:http://blog.csdn.net/lyhvoyage/article/details/41204175