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

题目分析:定义状态dp(i,j)表示找到了 i 种程序,并且出现在了 j 个程序中还需要的平均时间。则状态转移方程为:

dp(i,j)=i/n*j/m*dp(i,j)+(n-i)/n*j/m*dp(i+1,j)+i/n*(m-j)/m*dp(i,j+1)+(n-i)/n*(m-j)/m*dp(i+1,j+1)+1。

逆推之。

ps:这道题的题意不好懂。。

代码如下:

# include<iostream>
# include<cstdio>
# include<cstring>
# include<algorithm>
using namespace std; int n,m;
double dp[1005][1005]; int main()
{
while(~scanf("%d%d",&n,&m))
{
memset(dp,0,sizeof(dp));
for(int i=n;i>=0;--i){
for(int j=m;j>=0;--j){
if(i==n&&j==m) continue;
double right=(double(m-j)*i)/n/m;
double low=(double(n-i)*j)/n/m;
double rl=(double(n-i)*(m-j))/n/m;
double th=1.0-((double)(i*j))/n/m;;
dp[i][j]=right*dp[i][j+1]+low*dp[i+1][j]+rl*dp[i+1][j+1]+1;
dp[i][j]/=th;
}
}
printf("%.4lf\n",dp[0][0]);
}
return 0;
}

  

POJ-2096 Collecting Bugs (概率DP求期望)的更多相关文章

  1. Poj 2096 Collecting Bugs (概率DP求期望)

    C - Collecting Bugs Time Limit:10000MS     Memory Limit:64000KB     64bit IO Format:%I64d & %I64 ...

  2. poj 2096 Collecting Bugs (概率dp 天数期望)

    题目链接 题意: 一个人受雇于某公司要找出某个软件的bugs和subcomponents,这个软件一共有n个bugs和s个subcomponents,每次他都能同时随机发现1个bug和1个subcom ...

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

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

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

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

  5. POJ 2096 Collecting Bugs (概率DP)

    题意:给定 n 类bug,和 s 个子系统,每天可以找出一个bug,求找出 n 类型的bug,并且 s 个都至少有一个的期望是多少. 析:应该是一个很简单的概率DP,dp[i][j] 表示已经从 j ...

  6. poj 2096 Collecting Bugs 概率dp 入门经典 难度:1

    Collecting Bugs Time Limit: 10000MS   Memory Limit: 64000K Total Submissions: 2745   Accepted: 1345 ...

  7. poj 2096 Collecting Bugs - 概率与期望 - 动态规划

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

  8. HDU3853-LOOPS(概率DP求期望)

    LOOPS Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 125536/65536 K (Java/Others) Total Su ...

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

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

  10. POJ 2096 Collecting Bugs 期望dp

    题目链接: http://poj.org/problem?id=2096 Collecting Bugs Time Limit: 10000MSMemory Limit: 64000K 问题描述 Iv ...

随机推荐

  1. Qt之美(一):D指针/私有实现

    The English version is available at: http://xizhizhu.blogspot.com/2010/11/beauty-of-qt-1-d-pointer-p ...

  2. centos上安装python3.6

    安装python3.6可能使用的依赖 # yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sql ...

  3. ELK学习笔记之ELK分析nginx日志

    0x00 配置FIlebeat搜集syslog #安装 rpm -ivh filebeat-6.2.3-x86_64.rpm mv /etc/filebeat/filebeat.yml /etc/fi ...

  4. go-restful 实现一个web server

    go web server 1. 在ubuntu上安装go. 在ubuntu14.04上目前,最高的版本是golang-1.6 $ sudo apt-get install  golang-1.6 $ ...

  5. 特征提取的综合实验(多种角度比较SIFT、SURF、BRISK、ORB算法)

    代码:https://files.cnblogs.com/files/jsxyhelu/main.zip 一.基本概念: 特征点提取在“目标识别.图像拼接.运动跟踪.图像检索.自动定位”等研究中起着重 ...

  6. 20145317 网络对抗技术 逆向与Bof基础

    20145317 网络对抗技术 逆向与Bof基础 实践要求 1. 掌握NOP,JNE,JE,JMP,CMP汇编指令的机器码 2. 掌握反汇编与十六进制编程器 3. 能正确修改机器指令改变程序执行流程 ...

  7. Java DecimalFormat 用法(数字格式化)

    我们经常要将数字进行格式化,比如取2位小数,这是最常见的.Java 提供 DecimalFormat 类,帮你用最快的速度将数字格式化为你需要的样子.下面是常用的例子: import java.tex ...

  8. C#中dll附加配置文件

    DLL-with-configuration-file带配置文件的dll http://www.codeproject.com/Tips/199441/DLL-with-configuration-f ...

  9. java画流程图【思路】

    java计算整数输入 <样例 画的第一张流程图 把脑子里的东西能清晰的表现出来 学编程必备

  10. Unity3D学习笔记(二):个体层次、绝对和局部坐标、V3平移旋转

    Directional Light:平行光源/方向性光源,用来模拟太阳光(角度只与旋转角度有关,与位置无关) Point Light:点光源,用来模拟灯泡,向四周发散光源 Spotlight:锥光源/ ...