Time Limit: 10000MS   Memory Limit: 64000K
Total Submissions: 5090   Accepted: 2529
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

Source

Northeastern Europe 2004, Northern Subregion
 
 

 /*by SilverN*/
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
const int mxn=;
int n,s;
double f[mxn][mxn];
int main(){
cin>>n>>s;
f[n][s]=;
for(int i=n;i>=;i--)
for(int j=s;j>=;j--){
if(i==n && j==s)continue;
f[i][j]=(f[i+][j]*(n-i)*j + f[i][j+]*i*(s-j) +
f[i+][j+]*(n-i)*(s-j)+n*s)/(double)(n*s-i*j);
}
printf("%.5f\n",f[][]);
return ;
}

POJ2096 Collecting Bugs的更多相关文章

  1. poj2096 Collecting Bugs(概率dp)

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

  2. poj2096 Collecting Bugs[期望dp]

    Collecting Bugs Time Limit: 10000MS   Memory Limit: 64000K Total Submissions: 5394   Accepted: 2670 ...

  3. POJ2096 Collecting Bugs(概率DP,求期望)

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

  4. [Poj2096]Collecting Bugs(入门期望dp)

    Collecting Bugs Time Limit: 10000MS   Memory Limit: 64000K Total Submissions: 6237   Accepted: 3065 ...

  5. [POJ2096] Collecting Bugs (概率dp)

    题目链接:http://poj.org/problem?id=2096 题目大意:有n种bug,有s个子系统.每天能够发现一个bug,属于一个种类并且属于一个子系统.问你每一种bug和每一个子系统都发 ...

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

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

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

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

  8. 【期望DP】[poj2096]Collecting Bugs

    偷一波翻译: 工程师可以花费一天去找出一个漏洞——这个漏洞可以是以前出现过的种类,也可能是未曾出现过的种类,同时,这个漏洞出现在每个系统的概率相同.要求得出找到n种漏洞,并且在每个系统中均发现漏洞的期 ...

  9. 【POJ2096】Collecting Bugs 期望

    [POJ2096]Collecting Bugs Description Ivan is fond of collecting. Unlike other people who collect pos ...

随机推荐

  1. SharePoint 2013 沙盒解决方案不能激活(激活按钮不可用)

    把沙盒解决方案上传到目标站点的"解决方案"库中,发现"激活"按钮是灰掉的,不可用. 首先,我想到的是权限不足,所以 "以管理员身份"启动IE ...

  2. 分别用ToolBar和自定义导航栏实现沉浸式状态栏

    一.ToolBar 1.在build.gradle中添加依赖,例如: compile 'com.android.support:appcompat-v7:23.4.0' 2.去掉应用的ActionBa ...

  3. swift-可选值

    swift的nil和OC有些不一样,OC只有对象可以用nil,swift基础类型(整形,浮点)没有值时也是nil,当初始化的时候,swift可以没有初始值的,产生了可选值Optional. 定义可选值 ...

  4. Windows下SVN服务器的搭建步骤

    1.下载svn服务端和客户端 服务端VISUALSVN SERVER:https://www.visualsvn.com/ 客户端TortoiseSVN:https://tortoisesvn.net ...

  5. Oracle常用函数汇总

    在Oracle OCP考试中,相当一部分知识点涉及到对于Oracle常见函数的考查.尽管Oracle官方文档SQL Language Reference中Functions一章内列举了所有Oracle ...

  6. 关于Mysql 触发器

    首先,测试版本 Mysql 5.6. 然后再看触发器的语法 CREATE [DEFINER = { user | CURRENT_USER }] TRIGGER trigger_name trigge ...

  7. php将对象数组转成普通数组

    不知道为什么,把数组序列化为json,然后存到redis(string类型).然后再取出来反序列化为数组,就变成对象数组了 thinkPHP普通数组取值$arr['key'] 对象数组取值$arr-& ...

  8. 树莓派3B初始化后一些必须的设置

    接上一篇,SSH已经登录成功(http://www.cnblogs.com/crosys/p/6220108.html) 1.树莓派系统的设置 1.1扩展系统空间 因为内存卡还有很多空间没有分配,第一 ...

  9. android onNewIntent调用时机

    (转自:http://www.cnblogs.com/zenfly/archive/2012/02/10/2345196.html) 在IntentActivity中重写下列方法:onCreate o ...

  10. ubuntu 安装 vmware 12

    安装VMware Workstation 12 ubuntu15.10安装VMware Workstation12的步骤如下: 1.在 https://download3.vmware.com/sof ...