Collecting Bugs
Time Limit: 10000MS   Memory Limit: 64000K
Total Submissions: 1899   Accepted: 901
Case Time Limit: 2000MS   Special Judge

Description

Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other material stuff, he collects software bugs. When Ivan gets a new program, he classifies all possible bugs into n categories. Each day he discovers exactly one bug in the program and adds information about it and its category into a spreadsheet. When he finds bugs in all bug categories, he calls the program disgusting, publishes this spreadsheet on his home page, and forgets completely about the program. 
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

Input file contains two integer numbers, n and s (0 < n, s <= 1 000).

Output

Output the expectation of the Ivan's working days needed to call the program disgusting, accurate to 4 digits after the decimal point.

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的更多相关文章

  1. poj2096 Collecting Bugs(概率dp)

    Collecting Bugs Time Limit: 10000MS   Memory Limit: 64000K Total Submissions: 1792   Accepted: 832 C ...

  2. poj 2096 Collecting Bugs 【概率DP】【逆向递推求期望】

    Collecting Bugs Time Limit: 10000MS   Memory Limit: 64000K Total Submissions: 3523   Accepted: 1740 ...

  3. POJ-2096 Collecting Bugs (概率DP求期望)

    题目大意:有n种bug,m个程序,小明每天能找到一个bug.每次bug出现的种类和所在程序都是等机会均等的,并且默认为bug的数目无限多.如果要使每种bug都至少找到一个并且每个程序中都至少找到一个b ...

  4. [poj2096] Collecting Bugs【概率dp 数学期望】

    传送门:http://poj.org/problem?id=2096 题面很长,大意就是说,有n种bug,s种系统,每一个bug只能属于n中bug中的一种,也只能属于s种系统中的一种.一天能找一个bu ...

  5. POJ - 2096 Collecting Bugs(概率dp)

    https://vjudge.net/problem/POJ-2096 题意 一个软件有s个子系统,会产生n种bug.某人一天发现一个bug,这个bug属于某种bug,发生在某个子系统中.求找到所有的 ...

  6. poj 2096 Collecting Bugs(期望 dp 概率 推导 分类讨论)

    Description Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other ...

  7. POJ 2096-Collecting Bugs(概率dp入门)

    题意: 有n种bug和s种系统bug,每天发现一种bug(可能已经发现过了)所有种bug被发现的概率相同,求所有bug被发现的期望天数. 分析: dp[i][j]发现i种bug,j种系统bug期望天数 ...

  8. POJ 2096 Collecting Bugs:期望dp

    题目链接:http://poj.org/problem?id=2096 题意: 有一个程序猿,他每天都会发现一个bug. bug共有n个种类.属于某一个种类的概率为1/n. 有s个子系统,每个bug属 ...

  9. POJ2096 概率dp 入门

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=118282#problem/B 挺好的一个题目: 不过刚开始嘛,看别人题解长知识.这个人写 ...

随机推荐

  1. Hue集成Hadoop和Hive

    一.环境准备 1.下载Hue:https://dl.dropboxusercontent.com/u/730827/hue/releases/3.12.0/hue-3.12.0.tgz 2.安装依赖 ...

  2. jmeter 实现登录一次,多次操作登录后的某一个功能

  3. vue非父子组件间通信

    有时候非父子关系的组件也需要通信.在简单的场景下,使用一个空的Vue实例作为中央事件总线: 有时候非父子关系的组件也需要通信.在简单的场景下,使用一个空的 Vue 实例作为中央事件总线: var bu ...

  4. 【C++小白成长撸】--矩阵乘法程序

    矩阵乘法是大学矩阵课程中,相比矩阵加减法比较困难的部分. 矩阵乘法的原理: 矩阵乘法在代码中实现 得到目标矩阵的一个元素,涉及两个求和符号,一个求和符号一个for循环,两个求和符号两个for循环,再加 ...

  5. vSphere笔记01~02

    Vmware vsphere 虚拟化 云和大数据的底层!!!! 分类 1.开源:openstack:Linux:难(无图形化) nosqleasystack公司 2.企业版本:vsphere sdn! ...

  6. 201521123001《Java程序设计》第6周学习总结

    1. 本周学习总结 1.1 面向对象学习暂告一段落,请使用思维导图,以封装.继承.多态为核心概念画一张思维导图,对面向对象思想进行一个总结. 注1:关键词与内容不求多,但概念之间的联系要清晰,内容覆盖 ...

  7. Java程序设计第三周学习总结

    1. 本周学习总结 2. 书面作业 Q1.代码阅读 public class Test1 { private int i = 1;//这行不能修改 private static int j = 2; ...

  8. 201521123105 第10周Java学习总结

    1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结异常与多线程相关内容. 2. 书面作业 本次PTA作业题集异常.多线程 1.finally 题目4-21.1 截图你的提交结果(出现 ...

  9. 接口测试入门(4)--接口自动化测试框架 / list和map用法 / 随机选取新闻 (随机数生成) / 接口相关id映射

    一.接口自动化测试框架 为了更好的组织测试方法,测试用例并且持续集成,我们选择了  java+testNG(测试用例组织)+gitlab(代码版本管理)+Jenkins(持续集成工具) 作为一整套的自 ...

  10. Java Map对象的遍历

    一般情况下Map的实现类中用的最多的是 HashMap . Map的遍历也就是迭代 1. 在for-each循环中使用entries来遍历  (既要取键,又要取值) Map<String, St ...