题意:

有n种选择,每种选择对应m种状态。每种选择发生的概率相等,每种选择中对应的每种状态发生的概率相等。

求n种选择和m种状态中每种至少发生一次的期望。

期望DP好别扭啊。要用倒推的方法。

dp[i][j]表示已经发生了i种选择,j种状态。

那么由dp[n][m]这个时刻到最终时刻的期望是0.

而我们的起始时刻是dp[0][0]。

而dp[i][j]可以转移到四种情况,

1 dp[i][j]本身

2 dp[i+1][j]

3 dp[i][j+1]

4 dp[i+1][j+1]

那么dp[i][j]表示的期望是他能够转移到别的所有的情况的期望乘其权值的和。

好的。这大概就是期望DP的精髓了...

#include<stdio.h>
#include<string.h>
double dp[][];
int main()
{
int n,m;
scanf("%d%d",&n,&m);
memset(dp,,sizeof(dp));
for(int i=n;i>=;i--)
{
for(int j=m;j>=;j--)
{
if(i!=n||j!=m)
dp[i][j]=(dp[i][j+]*(m-j)*i/((double)(m*n))+dp[i+][j]*(n-i)*j/((double)(m*n))+dp[i+][j+]*(n-i)*(m-j)/((double)(m*n))+)/((double)(-((double)(i*j))/(m*n)));
}
}
printf("%.4lf\n",dp[][]);
}

POJ 2096 【期望DP】的更多相关文章

  1. poj - 2096 概率dp (找bug)

    题意:一个人一天只能找1个bug ,这个bug属于s个子系统中的某一个子系统,属于n种bug 中的某一种 ,求 这个人找出n种bug ,并且s个系统都bug的期望 (每个系统的一定可以找出bug) 一 ...

  2. POJ 2096 (概率DP)

    题目链接: http://poj.org/problem?id=2096 题目大意:n种bug,s个子系统.每天随机找一个bug,种类随机,来自系统随机.问找齐n种bug,且每个子系统至少有一个bug ...

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

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

  4. 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< ...

  5. poj 2096 , zoj 3329 , hdu 4035 —— 期望DP

    题目:http://poj.org/problem?id=2096 题目好长...意思就是每次出现 x 和 y,问期望几次 x 集齐 n 种,y 集齐 s 种: 所以设 f[i][j] 表示已经有几种 ...

  6. POJ 2096 Collecting Bugs:期望dp

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

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

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

  8. POJ 2096 找bug 期望dp

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

  9. 期望DP

    BZOJ 1415 #include <iostream> #include <cstring> #include <algorithm> #include < ...

随机推荐

  1. Android Afinal框架(二)

    框架地址:https://github.com/yangfuhai/afinal 对应的源码: net.tsz.afinal.annotation.view.* FinalActivity Final ...

  2. SmartDo数据挖掘思路

    SmartDo数据挖掘思路 数据挖掘部分: 数据挖掘的主要网址为: https://www.amazon.com/Best-Sellers/zgbs 挖掘部分为网址左边的入口,大约20多个,其中页面分 ...

  3. java中的堆、栈、常量池以及String类型的两种声明

    参考自http://blog.sina.com.cn/s/blog_798b04f90100ta67.html http://www.cnblogs.com/fguozhu/articles/2661 ...

  4. Hermes:来自腾讯的实时检索分析平台

    实时检索分析平台(Hermes)是腾讯数据平台部为大数据分析业务提供一套实时的.多维的.交互式的查询.统计.分析系统,为各个产品在大数据的统计分析方面提供完整的解决方案,让万级维度.千亿级数据下的秒级 ...

  5. 服务器安全狗,支持Linux/windows

    安全狗: www.safedog.cn 防DDOS  sql注入检测

  6. Web前端相关

    1)emmet2)prettify3)angularjs4)coffeescript5)bower (nodejs)6)requirejs

  7. 05 Linux下开发JSP项目(Hello world)

    测试环境: 主机系统:Win 7 虚拟机:VMware workstation 11.1.0 虚拟机OS: centos 6.5 64位 Kernel 2.6.32-431-e16.x86_64 My ...

  8. ntp.conf:很少有人提及的事

    [你可以到ntp.org下个ntp server的源代码,里面有HTML格式的文档,内容很全面.] [REF: http://doc.ntp.org/] Comprehensive List of C ...

  9. [platform]新旧内核的device设备注册对比

    转自:http://blog.chinaunix.net/uid-7332782-id-3268801.html 1. Version2.6内核启动过程 start_kernel( ) //板子上电启 ...

  10. byte[] 与字符串转换

    //取值之后进行 StringBuffer buffer=new StringBuffer(); for (int i = 0; i < enBytes.length; i++) { if(i! ...