泊松分布。。。。

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

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath> using namespace std; double boshon(int x,double r)
{
double ans=exp(-r)*pow(r,x);
for(int i=;i<=x;i++)
{
ans=ans/i;
}
return ans;
} int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int x;
double y;
cin>>x>>y;
double ans=.;
for(int i=;i<=x;i++)
{
ans+=boshon(i,y);
}
printf("%.3lf\n",ans);
}
return ;
}

ZOJ 3696 Alien's Organ的更多相关文章

  1. ZOJ 3696 Alien's Organ(泊松定理,期望值)

    Alien's Organ Time Limit: 2 Seconds      Memory Limit: 65536 KB There's an alien whose name is Marja ...

  2. ZOJ 3696 Alien's Organ 概率论 泊松分布

    看了好久的题,但还是看得一脸蒙圈,感觉完全无从下手,我的队友告诉我可能是正太分布之类的,但我感觉不太像,后来才听同学说是泊松分布,才恍然大悟,概率论刚刚学过这里不久,不禁感叹,学会了还要会用啊... ...

  3. zoj 3696 Alien&#39;s Organ(泊松分布)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3696 Alien's Organ Time Limit: 2 S ...

  4. ****K - Alien's Organ

    K - Alien's Organ Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Sub ...

  5. ZOJ3696 Alien's Organ 2017-04-06 23:16 51人阅读 评论(0) 收藏

    Alien's Organ Time Limit: 2 Seconds      Memory Limit: 65536 KB There's an alien whose name is Marja ...

  6. zoj3696(泊松分布)

    p(k)=(y^k) / (k!) * e^(-y) 其中的y就是平均值 k就是我们要求的大小. Alien's Organ Time Limit: 2 Seconds      Memory Lim ...

  7. ZOJ 1825 compoud words

    题目大意:输入一串递增的单词序列,需要找出符合条件的单词递增输出,条件是:将一个单词拆成左右两个单词后,能在输入中找到这两个单词.例如单词 alien,可以拆成 a 和 lien,而输入中刚好同时有a ...

  8. ZOJ People Counting

    第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ  3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...

  9. [LeetCode] Alien Dictionary 另类字典

    There is a new alien language which uses the latin alphabet. However, the order among letters are un ...

随机推荐

  1. 自定义框架(MyMvc)

    //初次接触自定义框架,简单的登录功能的实现流程:: 当我们实现登录功能的时候,首先会创建一个login.jsp 会写这些登录表单 <form action="loginAction. ...

  2. [No000074]C#创建桌面快捷方式

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  3. http协议进阶(三)补充:报文首部

    之前写的关于报文首部的传送门: 报文首部:http://www.cnblogs.com/imyalost/p/5708445.html 通用首部字段:http://www.cnblogs.com/im ...

  4. IIS上部署Net.Core

    部署: 1.安装vc_redist.x64vc_redist.x64 2.安装DotNetCore.1.0.0.RC2-WindowsHosting 3.安装DotNetCore.1.0.0-SDK. ...

  5. SQL笔记

    1.增加.删除约束 ALTER TABLE 表名 ADD CONSTRAINT 约束名 UNIQUE(列1名,列名2) ALTER TABLE 表名 DROP CONSTRAINT 约束名 2.查询更 ...

  6. Linux基础 - scp免密码登陆进行远程文件同步

    在工作中经常有遇到需要脚本自动化同步文件的地方,比如数据库异地备份.假设有两台机子A(192.168.16.218)和B(192.168.16.117),需要能够让A免密码连接B. 先来看看正常的ss ...

  7. [Word]中批量修改图片大小和缩放比例方法

    最近小编遇到一个问题:需要将一篇厘米.打开.宏名起好了,单击"创建"进入.返回word,工具-宏-宏(或者直接按Alt+F8),再次进入宏的界面,选择刚才编辑好的宏,并单击&quo ...

  8. K-means聚类算法

    聚类分析(英语:Cluster analysis,亦称为群集分析) K-means也是聚类算法中最简单的一种了,但是里面包含的思想却是不一般.最早我使用并实现这个算法是在学习韩爷爷那本数据挖掘的书中, ...

  9. [HTTP Protocol] 200 OK (from cache)和304 Not Modified

    含义 200 OK (from cache)直接从缓存中获取的内容并未请求服务器 304 Not Modified 请求服务器并和服务器比较 If-Modified-Since,若文件未改变,服务器返 ...

  10. Mbatis Oracle 第一次插入失败 useGeneratedKeys

    <insert id="insertAgentInfo" parameterType="pd" useGeneratedKeys="false& ...