题意:

有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. 解决 nginx https反向代理http协议 302重定向localtion到http问题

    location /rest { #proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remot ...

  2. shiro权限验证标签

    实例: spring-shiro.xml /admin/repairType/index = roles["ROLE_ADMIN"] /admin/user=roles[" ...

  3. 手机App开发

    /* * 登录:输入 */ public void login(String user, String pwd, TextHttpResponseHandler responsehandler) { ...

  4. 使用CAJViewer 提取PDF文件中的文字

    使用 CAJViewer 7.2 软件,把pdf格式的文件提取出文字. 操作步骤参考:http://jingyan.baidu.com/article/d45ad148cd06e469552b800f ...

  5. jQuery validate基本原则

    Markup recommendations Each input has a label associated with it: The for-attribute of the label ref ...

  6. 【jmeter】non-gui模式运行

    operty文件,默认是使用JMETER_HOME/bin目录下的jmeter.properties,如果用户自定义有其它的配置,在这里加上 #用法如下: -p user.properties -q, ...

  7. 【linux】locate介绍

    Locale和everything 类似,有本地的检索库,它会自动更新检索库,但新创建的文件,不能用locale 查到,需要手动更新检索库update db 才能搜索到,在/tmp 目录下的文件不能搜 ...

  8. 清理java环境

    system32中存在3个java*.exe文件,分别是: c:/windows/system32/java.exe c:/windows/system32/javaw.exe c:/windows/ ...

  9. c# string 数组转 list

    string str = "1,11,121,131"; var arr = str.Split(','); List<string> list = new List& ...

  10. 【转】七个例子帮你更好地理解 CPU 缓存

    我的大多数读者都知道缓存是一种快速.小型.存储最近已访问的内存的地方.这个描述相当准确,但是深入处理器缓存如何工作的"枯燥"细节,会对尝试理解程序性能有很大帮助. 在这篇博文中,我 ...