Collecting Bugs poj2096 概率DP
| Time Limit: 10000MS | Memory Limit: 64000K | |
| Total Submissions: 1899 | Accepted: 901 | |
| Case Time Limit: 2000MS | Special Judge |
Description
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.
Input
Output
Sample Input
1 2
Sample Output
3.0000
#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
double dp[][];
int main()
{
int n,s,i,j;
cin>>n>>s;
memset(dp,,sizeof(dp));
for(i=n;i>=;i--)
{
for(j=s;j>=;j--)
{
if(i==n&&j==s)continue;
dp[i][j]=(n*s+(n-i)*j*dp[i+][j]+i*(s-j)*dp[i][j+]+(n-i)*(s-j)*dp[i+][j+])/(1.0*n*s-i*j);
}
}
printf("%.4lf\n",dp[][]);
}
Collecting Bugs poj2096 概率DP的更多相关文章
- poj2096 Collecting Bugs(概率dp)
Collecting Bugs Time Limit: 10000MS Memory Limit: 64000K Total Submissions: 1792 Accepted: 832 C ...
- poj 2096 Collecting Bugs 【概率DP】【逆向递推求期望】
Collecting Bugs Time Limit: 10000MS Memory Limit: 64000K Total Submissions: 3523 Accepted: 1740 ...
- POJ-2096 Collecting Bugs (概率DP求期望)
题目大意:有n种bug,m个程序,小明每天能找到一个bug.每次bug出现的种类和所在程序都是等机会均等的,并且默认为bug的数目无限多.如果要使每种bug都至少找到一个并且每个程序中都至少找到一个b ...
- [poj2096] Collecting Bugs【概率dp 数学期望】
传送门:http://poj.org/problem?id=2096 题面很长,大意就是说,有n种bug,s种系统,每一个bug只能属于n中bug中的一种,也只能属于s种系统中的一种.一天能找一个bu ...
- POJ - 2096 Collecting Bugs(概率dp)
https://vjudge.net/problem/POJ-2096 题意 一个软件有s个子系统,会产生n种bug.某人一天发现一个bug,这个bug属于某种bug,发生在某个子系统中.求找到所有的 ...
- poj 2096 Collecting Bugs(期望 dp 概率 推导 分类讨论)
Description Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other ...
- POJ 2096-Collecting Bugs(概率dp入门)
题意: 有n种bug和s种系统bug,每天发现一种bug(可能已经发现过了)所有种bug被发现的概率相同,求所有bug被发现的期望天数. 分析: dp[i][j]发现i种bug,j种系统bug期望天数 ...
- POJ 2096 Collecting Bugs:期望dp
题目链接:http://poj.org/problem?id=2096 题意: 有一个程序猿,他每天都会发现一个bug. bug共有n个种类.属于某一个种类的概率为1/n. 有s个子系统,每个bug属 ...
- POJ2096 概率dp 入门
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=118282#problem/B 挺好的一个题目: 不过刚开始嘛,看别人题解长知识.这个人写 ...
随机推荐
- 微信H5支付:网络环境未能通过安全验证,请稍后再试。解决办法(PHP版)
前(tu)言(cao) (这段前言纯属吐槽,着急解决问题的小伙伴,赶紧看正文吧) 最近做了支付宝和微信支付,先做的是PC端网站的支付,就是出个二维码,然后手机扫描支付,当然支付宝在扫码页面支持登录支付 ...
- sed修炼系列(一):花拳绣腿之入门篇
本文为花拳绣腿招式入门篇,主要目的是入门,为看懂sed修炼系列(二):武功心法做准备.虽然是入门篇,只介绍了基本工作机制以及一些选项和命令,但其中仍然包括了很多sed的工作机制细节.对比网上各sed相 ...
- Git 入门篇
什么是Git Git是Linux发明者Linus开发的一款新时代的版本控制系统. Git安装 Mac:https://sourceforge.net/projects/git-osx-instal ...
- Vue双向数据绑定原理解析
基本原理 Vue.采用数据劫持结合发布者-订阅者模式的方式,通过Object.defineProperty()来劫持各个属性的setter和getter,数据变动时发布消息给订阅者,触发相应函数的回调 ...
- 那么 Appium 到底是怎么工作的呢?
因为官网文档写的没有梯度,作为新手的我花了好几个小时硬是没看明白它是怎么工作的. 网上教程也基本都是翻译,所以结构很复杂.和其他技术耦合度很高,且没有说明. 我自己总结了一份超简单 Appium 自动 ...
- [转] Java se 7新特性研究(二)
详见: http://blog.yemou.net/article/query/info/tytfjhfascvhzxcytp82 今天主要研究Java se 7中异常处理的新功能.从今天开始正在 ...
- java基础学习——集合
-------|List: 有存储顺序, 可重复-----------|ArrayList: 数组实现, 查找快, 增删慢,由于是数组实现, 在增和删的时候会牵扯到数组增容, 以及拷贝元素. 所以慢. ...
- 详解 anjularjs的ui-route(多视图、视图嵌套、视图传参)
最近整理了一下anjularjs的第三方插件ui-route,在这就以一个demo的形式讲解一下.整片博客均以开头的demo代码为例.下边是个目录,大家可以酌情直接跳转浏览. 1. demo的代码 2 ...
- Project 3:N级魔方阵
魔方阵:由n*n个数字所组成的n阶方阵,具有各对角线,各横列与纵行的数字和都相等的性质,称为魔方阵.而这个相等的和称为魔术数字.若填入的数字是从1到n*n,称此种魔方阵为n阶正规魔方阵. 目标:输入一 ...
- .net asp mvc 如何从后端返回数据对象
今天在做项目时,有一个需求:获取从控制器返回的数组对象,方法如下 public ActionResult GetAllFiles() { string dir = Server.MapPath(&qu ...