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

——————————————————————————————————————

输入N和入,入表示平均每天产生多少个物品,求产生物品在N以内的概率是多少?

思路:带入泊松分布定理即可

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cctype>
#include <sstream>
#include <climits>
#include <unordered_map> using namespace std; #define LL long long
const int INF=0x3f3f3f3f; const double e=exp(1);
int n;
double p; int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d%lf",&n,&p);
double ans=pow(e,-p);
double ans1=1;
double k=p;
for(int i=2;i<=n+1;i++)
{
ans1+=k;
k=k*p/i;
}
ans=ans*ans1;
printf("%.3f\n",ans);
}
return 0;
}
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

ZOJ3696 Alien's Organ 2017-04-06 23:16 51人阅读 评论(0) 收藏的更多相关文章

  1. HDU4081 Qin Shi Huang's National Road System 2017-05-10 23:16 41人阅读 评论(0) 收藏

    Qin Shi Huang's National Road System                                                                 ...

  2. 团体程序设计天梯赛L1-027 出租 2017-03-23 23:16 40人阅读 评论(0) 收藏

    L1-027. 出租 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 下面是新浪微博上曾经很火的一张图: 一时间网上一片求救声, ...

  3. ZOJ2482 IP Address 2017-04-18 23:11 44人阅读 评论(0) 收藏

    IP Address Time Limit: 2 Seconds      Memory Limit: 65536 KB Suppose you are reading byte streams fr ...

  4. 动态链接库(DLL) 分类: c/c++ 2015-01-04 23:30 423人阅读 评论(0) 收藏

    动态链接库:我们经常把常用的代码制作成一个可执行模块供其他可执行文件调用,这样的模块称为链接库,分为动态链接库和静态链接库. 对于静态链接库,LIB包含具体实现代码且会被包含进EXE中,导致文件过大, ...

  5. NYOJ-235 zb的生日 AC 分类: NYOJ 2013-12-30 23:10 183人阅读 评论(0) 收藏

    DFS算法: #include<stdio.h> #include<math.h> void find(int k,int w); int num[23]={0}; int m ...

  6. HDU 2034 人见人爱A-B 分类: ACM 2015-06-23 23:42 9人阅读 评论(0) 收藏

    人见人爱A-B Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Su ...

  7. HDU 2035 人见人爱A^B 分类: ACM 2015-06-22 23:54 9人阅读 评论(0) 收藏

    人见人爱A^B Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Su ...

  8. HDU2033 人见人爱A+B 分类: ACM 2015-06-21 23:05 13人阅读 评论(0) 收藏

    人见人爱A+B Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Su ...

  9. 认识C++中的临时对象temporary object 分类: C/C++ 2015-05-11 23:20 137人阅读 评论(0) 收藏

    C++中临时对象又称无名对象.临时对象主要出现在如下场景. 1.建立一个没有命名的非堆(non-heap)对象,也就是无名对象时,会产生临时对象. Integer inte= Integer(5); ...

随机推荐

  1. 你正在从一个声称代表如下的证书颁发机构安装证书 alipay truest network,希望能知道程序是怎么实现的或相关资料

    你正在从一个声称代表如下的证书颁发机构安装证书 alipay truest network,希望能知道程序是怎么实现的或相关资料

  2. Remi 安装源

    Remi repository 是包含最新版本 PHP 和 MySQL 包的 Linux 源,由 Remi 提供维护.有个这个源之后,使用 YUM 安装或更新 PHP.MySQL.phpMyAdmin ...

  3. zeromq测试

    debian sudo apt-get install libzmq3-dev pip install zmq client.py #coding: utf-8 import zmq context ...

  4. ptthon 网络编程

    网络编程 网络目的 : 数据的传输 网络数据传输是一个复杂的过程 ISO :国际标准化组织 OSI 七层模型 --> 网络通信标准化流程 应用层 : 提供用户服务,具体内容由特定程序规定 表示层 ...

  5. java中一个简单的下载示例

    首先在tomcat服务器下的webapps的download项目下建一个doc文件夹,再建个test.doc.防止控指针异常 DownLoad.java代码 package com.down; imp ...

  6. 原生态JDBC问题的总结

    package com.js.ai.modules.aiyq.testf; import java.sql.Connection; import java.sql.DriverManager; imp ...

  7. ES6系列_16之模块化操作

    ES6的模块化操作主要包括两个方面. (1)export :负责进行模块化,也是模块的输出. (2)import : 负责把模块引,也是模块的引入操作. export的用法: export可以让我们把 ...

  8. Python实践练习:疯狂填词

    题目 创建一个疯狂填词(Mad Libs)程序,它将读入文本文件,并让用户在该文本文件中出现 ADJECTIVE.NOUN.ADVERB 或 VERB 等单词的地方,加上他们自己的文本. 例如,一个文 ...

  9. #region 常量和静态变量静态类readonly

    #region 常量和静态变量静态类readonly //---------------------------------------------------------------------- ...

  10. 【334】Python Object-Oriented Programming

    Reference: Python中self用法详解 __init__ 方法: 私有变量. Reference: [290]Python 函数 class 里面的 function 创建与此一致,只是 ...