zoj 3696 Alien's Organ

来源:互联网 发布:骚男的辣条淘宝店网址 编辑:程序博客网 时间:2024/05/01 00:11
A -Alien's Organ
Crawling in process...Crawling failedTime Limit:2000MS    Memory Limit:65536KB     64bit IO Format:%lld & %llu
SubmitStatus

Description

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 thanN organs in one day?

Input

The first line contains a single integerT (0 ≤ T ≤ 10000), indicating there are T cases in total. Then the followingT 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

35 8.0008 5.0002 4.910

Sample Output

0.1910.9320.132
题意: 平均每天生产的λ 个,问每天生产不超过n的可能性?
引入

泊松分布:泊松分布公式

 泊松分布适合于描述单位时间(或空间)内随机事件发生的次数。如某一服务设施在一定时间内到达的人数,电话交换机接到呼叫的次数,汽车站台的候客人数,机器出现的故障数,自然灾害发生的次数,一块产品上的缺陷数,显微镜下单位分区内的细菌分布数等等。[1]观察事物平均发生m次的条件下,实际发生x次的概率P(x)可用下式表示:P(x)=(m^x/x!)*e^(-m)p ( 0 ) = e ^ (-m)称为泊松分布。例如采用0.05J/m2紫外线照射大肠杆菌时,每个基因组(~4×106核苷酸对)平均产生3个嘧啶二体。实际上每个基因组二体的分布是服从泊松分布的,将取如下形式:P(0)=e^(-3)=0.05;P(1)=(3/1!)e^(-3)=0.15;P(2)=(3^2/2!)e^(-3)=0.22;P(3)=0.22;P(4)=0.17;……P(0)是未产生二体的菌的存在概率,实际上其值的5%与采用0.05J/m2照射时的大肠杆菌uvrA-株,recA-株
(除去既不能修复又不能重组修复的二重突变)的生存率是一致的。由于该菌株每个基因组有一个二体就是致死量,
因此P(1),P(2)……就意味着全部死亡的概率。[2]基本套公式  就是这题了。。。以1为下界 sum = p(1)+p(2)+p(3)+.....+p(n) ;
代码:
   #include <stdio.h>  #include <iostream>  #include <cmath>  using namespace std;    int t;  int n;  double la;    int main()  {      cin >> t;      while(t --)      {          cin >> n >> la;          double it = 1, sum=1;          for(int i=1; i<=n ; ++i)          {              it *= la;               //it寄存 λ^k             it /= i;                //除掉阶乘。            sum += it;          }          sum *= exp(-la);         // Exp 函数 返回 e(自然对数的底)的幂次方。        printf("%.3lf\n", sum);      }      return 0;  }  
  完全是套公式!!!!
原创粉丝点击