POJ-2096 Collecting Bugs (概率DP求期望)
题目大意:有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求期望)的更多相关文章
- Poj 2096 Collecting Bugs (概率DP求期望)
C - Collecting Bugs Time Limit:10000MS Memory Limit:64000KB 64bit IO Format:%I64d & %I64 ...
- poj 2096 Collecting Bugs (概率dp 天数期望)
题目链接 题意: 一个人受雇于某公司要找出某个软件的bugs和subcomponents,这个软件一共有n个bugs和s个subcomponents,每次他都能同时随机发现1个bug和1个subcom ...
- POJ 2096 Collecting Bugs (概率DP,求期望)
Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other material stu ...
- POJ2096 Collecting Bugs(概率DP,求期望)
Collecting Bugs Ivan is fond of collecting. Unlike other people who collect post stamps, coins or ot ...
- POJ 2096 Collecting Bugs (概率DP)
题意:给定 n 类bug,和 s 个子系统,每天可以找出一个bug,求找出 n 类型的bug,并且 s 个都至少有一个的期望是多少. 析:应该是一个很简单的概率DP,dp[i][j] 表示已经从 j ...
- poj 2096 Collecting Bugs 概率dp 入门经典 难度:1
Collecting Bugs Time Limit: 10000MS Memory Limit: 64000K Total Submissions: 2745 Accepted: 1345 ...
- poj 2096 Collecting Bugs - 概率与期望 - 动态规划
Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other material stu ...
- HDU3853-LOOPS(概率DP求期望)
LOOPS Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 125536/65536 K (Java/Others) Total Su ...
- 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
题目链接: http://poj.org/problem?id=2096 Collecting Bugs Time Limit: 10000MSMemory Limit: 64000K 问题描述 Iv ...
随机推荐
- python3.4学习笔记(十九) 同一台机器同时安装 python2.7 和 python3.4的解决方法
python3.4学习笔记(十九) 同一台机器同时安装 python2.7 和 python3.4的解决方法 同一台机器同时安装 python2.7 和 python3.4不会冲突.安装在不同目录,然 ...
- 护眼色的RGB值和颜色代码汇总
源: 网上流行护眼色的RGB值和颜色代码汇总 网上流行护眼色的RGB值和颜色代码 在搜索引擎搜“护眼色”,就会搜出一堆关于保护眼睛的屏幕颜色文章,说的统统是一种颜色,有点像绿豆沙的颜色.方法就是在屏幕 ...
- CentOS7安装redis5.0
下载好redis5.0后解压在/tmp目录 cd /tmp/redis-/ make make过程中可能出现make[1]: *** [adlist.o] 错误 127,这是因为CentOS7默认没有 ...
- Unity3D之预设
预设的两个特性: 1.重用性.可以使我们快速方便的创建大量的重复性资源.这种创建是通过预设的实例化Instance操作来完成的 在Hierarchy视图中将实例物理添加到Assests中,此时图标 ...
- 20145322 Exp5 利用nmap扫描
20145322 Exp5 利用nmap扫描 实验过程 使用命令创建一个msf所需的数据库 service postgresql start msfdb start 使用命令msfconsole开启m ...
- Python3基础 __doc__ 单行与多行函数文档
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Android 开发环境配置图文教程(jdk+eclipse+android sdk)
一 相关下载(1) java JDK下载:进入该网页: http://java.sun.com/javase/downloads/index.jsp (或者直接点击下载)如下图: 选择 Downloa ...
- windows10下使用source insight出现"source insight program editor已停止工作"的问题
一.背景 1.1 OS 版本 windows 10 1.2 source insight版本 source insight 3.50.0034 二.解决方案 删除"我的文档"下面的source ins ...
- Visual Studio 项目模板制作(三)
前面,我们已经制作好了模板,然后放到相应的Template目录就可以在Visual Studio中使用 本篇,我们采用安装VSIX扩展的方式来安装模板,这种方式需要安装Visual Studio SD ...
- 04_Flume多节点load_balance实践
1.负载均衡场景 1)初始:上游Agent通过round_robin selector, 将event轮流发送给下游Collecotor1, Collector2 2)故障: 关闭Collector1 ...