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 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;
}
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) 收藏的更多相关文章
- HDU4081 Qin Shi Huang's National Road System 2017-05-10 23:16 41人阅读 评论(0) 收藏
Qin Shi Huang's National Road System ...
- 团体程序设计天梯赛L1-027 出租 2017-03-23 23:16 40人阅读 评论(0) 收藏
L1-027. 出租 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 下面是新浪微博上曾经很火的一张图: 一时间网上一片求救声, ...
- 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 ...
- 动态链接库(DLL) 分类: c/c++ 2015-01-04 23:30 423人阅读 评论(0) 收藏
动态链接库:我们经常把常用的代码制作成一个可执行模块供其他可执行文件调用,这样的模块称为链接库,分为动态链接库和静态链接库. 对于静态链接库,LIB包含具体实现代码且会被包含进EXE中,导致文件过大, ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 认识C++中的临时对象temporary object 分类: C/C++ 2015-05-11 23:20 137人阅读 评论(0) 收藏
C++中临时对象又称无名对象.临时对象主要出现在如下场景. 1.建立一个没有命名的非堆(non-heap)对象,也就是无名对象时,会产生临时对象. Integer inte= Integer(5); ...
随机推荐
- FreeFileSync 4.2 发布,文件夹比较和同步工具
FreeFileSync 是一款开源的文件夹比较和同步工具,可用于 Win 和 Lin 平台,最近发布了 4.2 版本. FreeFileSync 采用双面板设计,使用方法很简单: 在左面版和右面版上 ...
- 阿里云OSS linux使用备忘录
ossutil config example: accessKeyId = "AccessKeyId"; accessKeySecret = "AccessKeySecr ...
- WinCE全屏手写输入法
来源地址:http://www.dwhand.com/?page_id=570 WinCE全屏手写输入法 功能特点: 1.支持手写识别,智能拼音.仓颉.注音.笔画.五笔.ABC等输入模式. 2.支持各 ...
- 关于AOP无法切入同类调用方法的问题
一.前言 Spring AOP在使用过程中需要注意一些问题,也就是平时我们说的陷阱,这些陷阱的出现是由于Spring AOP的实现方式造成的.每一样技术都或多或少有它的局限性,很难称得上完美,只要掌握 ...
- Java-Runoob-高级教程-实例-环境设置实例:4.Java 实例 – 如何查看当前 Java 运行的版本?
ylbtech-Java-Runoob-高级教程-实例-环境设置实例:4.Java 实例 – 如何查看当前 Java 运行的版本? 1.返回顶部 1. Java 实例 - 如何查看当前 Java 运行 ...
- 我的solr学习笔记--solr admin 页面 检索调试
前言 Solr/Lucene是一个全文检索引擎,全文引擎和SQL引擎所不同的是强调部分相关度高的内容返回,而不是所有内容返回,所以部分内容包含在索引库中却无法命中是正常现象. 多数情况下我们 ...
- mybatis一对多关联查询+pagehelper->分页错误
mybatis一对多关联查询+pagehelper->分页错误. 现象: 网上其他人遇到的类似问题:https://segmentfault.com/q/1010000009692585 解决: ...
- 检测Python程序的执行效率
无意中被问到代码执行效率的问题,那就总结一下检测代码执行效率的几种方式: 一.装饰器 在函数上加装饰器,来得到函数的执行时间. def cst_time(func, *args, **kwargs): ...
- VS2010开发MFC ActiveX,摄像头拍照上传Webservice(2)
继续记录,第二步开发摄像头拍照功能. 使用vfw.h开发摄像头拍照功能,关于vfw网上有很多文章,很多代码可以参考 参考:http://blog.163.com/huangqiao_8/blog/st ...
- 提交iframe页面中的表单
function getIframeDoc(id){ var doc; if (document.all){//IE do ...