【poj2096】Collecting Bugs
题目描述
Two companies, Macrosoft and Microhard are in tight competition. Microhard wants to decrease sales of one Macrosoft program. They hire Ivan to prove that the program in question is disgusting. However, Ivan has a complicated problem. This new program has s subcomponents, and finding bugs of all types in each subcomponent would take too long before the target could be reached. So Ivan and Microhard agreed to use a simpler criteria --- Ivan should find at least one bug in each subsystem and at least one bug of each category.
Macrosoft knows about these plans and it wants to estimate the time that is required for Ivan to call its program disgusting. It's important because the company releases a new version soon, so it can correct its plans and release it quicker. Nobody would be interested in Ivan's opinion about the reliability of the obsolete version.
A bug found in the program can be of any category with equal probability. Similarly, the bug can be found in any given subsystem with equal probability. Any particular bug cannot belong to two different categories or happen simultaneously in two different subsystems. The number of bugs in the program is almost infinite, so the probability of finding a new bug of some category in some subsystem does not reduce after finding any number of bugs of that category in that subsystem.
Find an average time (in days of Ivan's work) required to name the program disgusting.
输入
输出
样例输入
1 2
样例输出
3.0000
题目大意
共有n种bug和s个系统,每天随机发现1个系统中的1种bug,问:发现所有种类的bug,且每个系统都发现bug的期望天数。
题解
期望dp
f[i][j] = f[i+1][j+1]*(n-i)/n*(s-j)/s + f[i][j+1]*i/n*(s-j)/s + f[i+1][j]*(n-i)/n*j/s + f[i][j]*i/n*j/s + 1
移项,合并同类项,化简
#include <cstdio>
double f[1002][1002];
int main()
{
int n , s , i , j;
scanf("%d%d" , &n , &s);
for(i = n ; i >= 0 ; i -- )
for(j = s ; j >= 0 ; j -- )
if(i != n || j != s)
f[i][j] = (f[i + 1][j + 1] * (n - i) * (s - j) + f[i][j + 1] * i * (s - j) + f[i + 1][j] * (n - i) * j + (n * s)) / (n * s - i * j);
printf("%.4lf\n" , f[0][0]);
return 0;
}
【poj2096】Collecting Bugs的更多相关文章
- 【POJ2096】Collecting Bugs 期望
[POJ2096]Collecting Bugs Description Ivan is fond of collecting. Unlike other people who collect pos ...
- 【poj2096】Collecting Bugs 期望dp
题目描述 Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other materia ...
- 【poj2096】 Collecting Bugs
http://poj.org/problem?id=2096 (题目链接) 题意 有一个程序,其中有s个子结构,每个子结构出bug的概率相等.bug总共分成n类,每种bug出现的概率相等.每天找出一个 ...
- 【POJ】【2096】Collecting Bugs
概率DP/数学期望 kuangbin总结中的第二题 大概题意:有n个子系统,s种bug,每次找出一个bug,这个bug属于第 i 个子系统的概率为1/n,是第 j 种bug的概率是1/s,问在每个子系 ...
- 【POJ 2096】 Collecting Bugs
[题目链接] http://poj.org/problem?id=2096 [算法] 概率DP [代码] #include <algorithm> #include <bitset& ...
- 【POJ 2096】Collecting Bugs 概率期望dp
题意 有s个系统,n种bug,小明每天找出一个bug,可能是任意一个系统的,可能是任意一种bug,即是某一系统的bug概率是1/s,是某一种bug概率是1/n. 求他找到s个系统的bug,n种bug, ...
- 【分享】Collecting all the cheat sheets
http://overapi.com/ 这个网站可以查询到所有与编程相关的各种技术,并给出详细的知识点(干货).
- poj 2096 Collecting Bugs 【概率DP】【逆向递推求期望】
Collecting Bugs Time Limit: 10000MS Memory Limit: 64000K Total Submissions: 3523 Accepted: 1740 ...
- poj2096 Collecting Bugs(概率dp)
Collecting Bugs Time Limit: 10000MS Memory Limit: 64000K Total Submissions: 1792 Accepted: 832 C ...
随机推荐
- MMORPG大型游戏设计与开发(服务器 游戏场景 动态场景与副本)
场景的内容讲解到今天算是暂时划上一个句号了,接下来为大家讲解的是AI部分(大型AI),如果有兴趣的朋友不妨持续关注这些文章,大家一起学习和进步.动态场景和副本是场景中特殊的类型,副本在这里想必已经是无 ...
- JS入门学习,编写一个简易月历
//今天最头疼的地方在于 getElementsByClassName()的 [] ~~ //错了N遍后只能说有点点头绪,如果不加[] 查找的就是全部吧 加上[]能精确控制的标签或者class < ...
- Windows7台式电脑怎么调节屏幕亮度
- 配置Jenkins使用Gitlab的代码库进行构建
1. 首先确认Jenkins上安装了Git plugin, 以及Subversion plugin Manage Jenkins -> Plugin Manager -> Availabl ...
- down的另一种用法
- TinyFrame系列:基于EFCodeFirst,IOC,AOP的轻型框架
TinyFrame开篇:基于CodeFirst的ORM TinyFrame续篇:整合Spring IOC实现依赖注入 TinyFrame再续篇:整合Spring AOP实现日志拦截 TinyFrame ...
- caffe的python接口学习(8):caffemodel中的参数及特征的抽取
如果用公式 y=f(wx+b) 来表示整个运算过程的话,那么w和b就是我们需要训练的东西,w称为权值,在cnn中也可以叫做卷积核(filter),b是偏置项.f是激活函数,有sigmoid.relu ...
- 2016-2017-2《程序设计与数据结构》学生博客&git@OSC
2016-2017-2<程序设计与数据结构>学生博客&git@OSC 博客园 20162301张师瑜 20162302杨京典 20162303石亚鑫 20162304张浩林 201 ...
- 关于Linux与Windows的区别的文章
你从来只用过Windows,从来没接触过UNIX,只知道把一个文件拽来拽去,只知道硬盘就是C: D: E:却从来没有研究过分区表,也许 会用VC编个程序,很习惯它的集成环境.... 有一天,不管什么原 ...
- 【技术贴】大型发布会现场的WiFi网络应该如何搭建?
WiFi网络的部署要远远比一般人想象的复杂,不是说放上几十个AP带宽就自动增加几十倍,恰恰相反,简单放几十个AP带宽会由于AP之间的竞争而 迅速使带宽下降为几乎不可用.实际上这个问题完全可以写一本书了 ...