POJ 2096-Collecting Bugs(概率dp入门)
题意:
有n种bug和s种系统bug,每天发现一种bug(可能已经发现过了)所有种bug被发现的概率相同,求所有bug被发现的期望天数。
分析:
dp[i][j]发现i种bug,j种系统bug期望天数,dp[n][s]=0;dp[0][0]即为所求
dp[i][j] = (n-i)*(s-j)/n/s*dp[i+1][j+1] + i*(s-j)/n/s*dp[i][j+1] + (n-i)*j/n/s*dp[i+1][j] +i*j/n/s*dp[i][j]+1;
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <complex>
#include <cassert>
#include <utility>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
typedef pair<int,int> PII;
typedef long long ll;
#define lson l,m,rt<<1
#define pi acos(-1.0)
#define rson m+1,r,rt<<11
#define All 1,N,1
#define read freopen("in.txt", "r", stdin)
#define N 1010
const ll INFll = 0x3f3f3f3f3f3f3f3fLL;
const int INF= 0x7ffffff;
const int mod = ;
using namespace std;
double dp[N][N];
int n, s;
double solve(){
dp[n][s] = 0.0;
for(int i = n; i >= ; i--) {
for(int j = s; j >= ; j--)
{
if(i == n && j == s)continue;
dp[i][j] = (n-i)*(s-j)*dp[i+][j+] + i*(s-j)*dp[i][j+] + (n-i)*j*dp[i+][j] + n*s;
dp[i][j] /= n*s - i*j;
}
}
return dp[][];
}
int main() {
while(~scanf("%d%d",&n,&s))
printf("%.4f\n", solve());
return ;
}
POJ 2096-Collecting Bugs(概率dp入门)的更多相关文章
- poj 2096 Collecting Bugs 概率dp 入门经典 难度:1
Collecting Bugs Time Limit: 10000MS Memory Limit: 64000K Total Submissions: 2745 Accepted: 1345 ...
- POJ 2096 Collecting Bugs (概率DP,求期望)
Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other material stu ...
- poj 2096 Collecting Bugs (概率dp 天数期望)
题目链接 题意: 一个人受雇于某公司要找出某个软件的bugs和subcomponents,这个软件一共有n个bugs和s个subcomponents,每次他都能同时随机发现1个bug和1个subcom ...
- Poj 2096 Collecting Bugs (概率DP求期望)
C - Collecting Bugs Time Limit:10000MS Memory Limit:64000KB 64bit IO Format:%I64d & %I64 ...
- POJ 2096 Collecting Bugs (概率DP)
题意:给定 n 类bug,和 s 个子系统,每天可以找出一个bug,求找出 n 类型的bug,并且 s 个都至少有一个的期望是多少. 析:应该是一个很简单的概率DP,dp[i][j] 表示已经从 j ...
- POJ 2096 Collecting Bugs 期望dp
题目链接: http://poj.org/problem?id=2096 Collecting Bugs Time Limit: 10000MSMemory Limit: 64000K 问题描述 Iv ...
- poj 2096 Collecting Bugs - 概率与期望 - 动态规划
Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other material stu ...
- poj 2096 Collecting Bugs 【概率DP】【逆向递推求期望】
Collecting Bugs Time Limit: 10000MS Memory Limit: 64000K Total Submissions: 3523 Accepted: 1740 ...
- poj 2096 Collecting Bugs && ZOJ 3329 One Person Game && hdu 4035 Maze——期望DP
poj 2096 题目:http://poj.org/problem?id=2096 f[ i ][ j ] 表示收集了 i 个 n 的那个. j 个 s 的那个的期望步数. #include< ...
- Collecting Bugs (概率dp)
Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other material stu ...
随机推荐
- VisualSvn Server介绍
1 .VisualSvn Server VisualSvn Server是免费的,而VisualSvn是收费的.VisualSvn是Svn的客户端,和Visual Studio集成在一起,但是不免费 ...
- 用cxSelect插件补充一下回显过滤项功能
这个在DJANGO里,最好在过滤之后,让用户知道自己过滤的选择.所以要定位默认值. 1,在HTML文件里显示默认值: <form class="uk-form" name=& ...
- Oracle的学习一:安装与卸载、sql *plus常用命令、Oracle用户管理
1.为什么学习oracle? 性能优越: 小型数据库 中型数据库 大型数据库 acess.foxbase mysql.sql server.informix sybase.oracle.db2 复杂量 ...
- jquery控制按钮的禁用与启用
jquery禁用a标签方法1: $(document).ready(function () { $("a").each(function () { var textValue = ...
- 合并傻子//区间dp
P1062 合并傻子 时间: 1000ms / 空间: 131072KiB / Java类名: Main 背景 从前有一堆傻子,钟某人要合并他们~但是,合并傻子是要掉RP的...... 描述 在一个园 ...
- lintcode :最长上升连续子序列
题目: 最长上升连续子序列 给定一个整数数组(下标从 0 到 n-1, n 表示整个数组的规模),请找出该数组中的最长上升连续子序列.(最长上升连续子序列可以定义为从右到左或从左到右的序列.) 样例 ...
- Tomcat部署Web应用方法总结
转载:http://m.blog.csdn.net/blog/u012516903/15741727 Tomcat部署Web应用方法总结 在Tomcat中部署Java Web应用程序有两种方式:静态部 ...
- ScannerTest-------double string
import java.util.*; public class ScannerTest { public static void main(String[] args){ Scanner scann ...
- 转TransactionProxyFactoryBean代理事务
<?xml version="1.0" encoding="GBK"?> <!-- 指定Spring配置文件的DTD信息 --> < ...
- 关于java -version版本问题
因为安装了Oracle,而Oracel会自带JDK,安装完成后,会自动把自己的JDK设置在最前面(path变量里). 这就是为什么结果与事实不相同的原因. 解决方法: 进入系统环境变量,找到path变 ...