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); ...
随机推荐
- BeagleBoneBlack Linux开发相关链接收藏
ubuntu挂载vdi文件 官方linux代码地址 官方devicetree代码地址 [转]使用BBB的device tree和cape(重新整理版) iio: input: ti_am335x_ad ...
- jquery 绘图工具 flot 学习笔记
今天想做一个统计图表,像163博客的流量统计一样的,借助 flot 实现了,而且很简单. flot网址:http://code.google.com/p/flot/ 下载 JS 文件,使用方法和 jq ...
- 如何查看oracle表空间是否自动扩展
select file_name,autoextensible,increment_by from dba_data_files
- win7 安装 node-sass报错
由于国内网络问题,所以会导致下载node-sass二进制包失败 只需要在 ~/.npmrc(当前用户家目录下)添加下面一行: sass_binary_site=https://npm.taobao.o ...
- Linq模型ObjectContext下查看Sql语句。
ObjectContext 并没有提供 LINQ to SQL DataContext.Log 这样的功能,要查看实际生成的 T-SQL 语句,要么借助 SQL Server Sql Profiler ...
- SpringMVC+hibernate4事务处理
首先spring-hibernate.xml里配置事务: <!-- 配置事务管理器 --> <bean id="transactionManager" class ...
- bzoj4891: [Tjoi2017]龙舟
求$\frac{b_1b_2b_3...b_m}{a_1a_2a_3...a_m}\%M$ M<=1e18,m<=100000,数据组数<=50 用pollard-rho分解M的质因 ...
- 替换res\drawable中的图片
现象 在android开发中,经常会需要替换res\drawable中的图片,打开res\layout下的文件预览布局页面发现图片已经被替换,但在模拟器或者真实机器上运行时发现该图片并没有被替换,还是 ...
- PDF预览之PDFObject.js总结
get from:PDF预览之PDFObject.js总结 PDFObject.js - 将PDF嵌入到一个div内,而不是占据整个页面(要求浏览器支持显示PDF,不支持,可配置PDF.js来实现 ...
- [ML] Gradient Descend Algorithm [Octave code]
function [theta, J_history] = gradientDescentMulti(X, y, theta, alpha, num_iters) m = length(y); % n ...