zoukankan      html  css  js  c++  java
  • ZOJ 3696 Alien'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 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

    Author: FAN, Yuzhe
    Contest: The 13th Zhejiang University Programming Contest

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstring>
     4 #include <cmath>
     5  
     6 using namespace std;
     7  
     8 double boshon(int x,double r)
     9 {
    10     double ans=exp(-r)*pow(r,x);
    11     for(int i=1;i<=x;i++)
    12     {
    13         ans=ans/i;
    14     }
    15     return ans;
    16 }
    17  
    18 int main()
    19 {
    20     int t;
    21     scanf("%d",&t);
    22     while(t--)
    23     {
    24         int x;
    25         double y;
    26         cin>>x>>y;
    27         double ans=0.;
    28         for(int i=0;i<=x;i++)
    29         {
    30             ans+=boshon(i,y);
    31         }
    32         printf("%.3lf
    ",ans);
    33     }
    34     return 0;
    35 }
  • 相关阅读:
    【NodeJS】---express配置ejs mongoose route等
    【CSS3】---层模型position之fixed固定定位、absolute绝对定位和relative相对定位
    【CSS3】---:before :after生成内容
    px转rem的填坑之路
    markdown编写文件目录结构
    js reduce数组转对象
    处理Promise.reject()
    js事件循环
    为什么[] == false 为true
    为什么不建议用var
  • 原文地址:https://www.cnblogs.com/CKboss/p/3409126.html
Copyright © 2011-2022 走看看