题目链接

  • 题意:

    给一个n*m的矩阵,每天随机的在未放棋子的格子上放一个棋子。求每行至少有一个棋子,每列至少有一个棋子的天数的期望

     (1 <= N, M <= 50).
  • 分析:

    比較明显的概率DP,难点在于怎样设计状态。覆盖了多少行和列是不可缺少的,之后比較关键的就是想到还有一个属性:多少个交叉点(即放过的点)
double dp[55][55][2550];
bool vis[55][55][2550];
int tot;
int n, m;
inline double getp(int xx, int yy)
{
return (xx * 1.0) / yy;
}
double dpf(int x, int y, int z)
{
if (x > n || y > m || z > tot) return 0;
if (x == n && y == m) return 0.0; if (vis[x][y][z]) return dp[x][y][z];
vis[x][y][z] = true; int a = x * y - z;
int b = tot - (x * m + y * n - x * y);
int xc = x * m - x * y;
int yc = y * n - x * y; int sum = a + b + xc + yc;
dp[x][y][z] = 0; if (a)
dp[x][y][z] += getp(a, sum) * dpf(x, y, z + 1);
if (b)
dp[x][y][z] += getp(b, sum) * dpf(x + 1, y + 1, z + 1);
if (xc)
dp[x][y][z] += getp(xc, sum) * dpf(x, y + 1, z + 1);
if (yc)
dp[x][y][z] += getp(yc, sum) * dpf(x + 1, y, z + 1);
dp[x][y][z] += 1.0;
return dp[x][y][z];
} int main()
{
int T;
RI(T);
while (T--)
{
RII(n, m); tot = n * m;
memset(vis, 0, sizeof(vis));
printf("%.12lf\n", dpf(0, 0, 0));
}
return 0;
}

2014牡丹江——Domination的更多相关文章

  1. 2014牡丹江D Domination

    Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headm ...

  2. zoj 3822 Domination(2014牡丹江区域赛D称号)

    Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headm ...

  3. zoj 3822 Domination(2014牡丹江区域赛D题) (概率dp)

    3799567 2014-10-14 10:13:59                                                                     Acce ...

  4. zoj 3822 Domination 概率dp 2014牡丹江站D题

    Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headm ...

  5. ACM学习历程——ZOJ 3822 Domination (2014牡丹江区域赛 D题)(概率,数学递推)

    Description Edward is the headmaster of Marjar University. He is enthusiastic about chess and often ...

  6. 2014 牡丹江区域赛 B D I

    http://acm.zju.edu.cn/onlinejudge/showContestProblems.do?contestId=358 The 2014 ACM-ICPC Asia Mudanj ...

  7. ZOJ 3829 Known Notation (2014牡丹江H称号)

    主题链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do? problemId=5383 Known Notation Time Limit: 2 S ...

  8. The 2014 ACM-ICPC Asia Mudanjiang Regional Contest(2014牡丹江区域赛)

    The 2014 ACM-ICPC Asia Mudanjiang Regional Contest 题目链接 没去现场.做的网络同步赛.感觉还能够,搞了6题 A:这是签到题,对于A堆除掉.假设没剩余 ...

  9. zoj 3820(2014牡丹江现场赛B题)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5374 思路:题目的意思是求树上的两点,使得树上其余的点到其中一个点的 ...

随机推荐

  1. Java基础知识强化36:StringBuffer类之StringBuffer的概述

    1. StringBuffer类概述: (1)String的缺陷: 我们如果对字符串进行拼接操作,每次拼接,都会构造一个新的String对象,既耗时,又浪费空间.如下图: (2)StringBuffe ...

  2. VritualBox 中Debian安装tool

    VritualBox 中Debian安装tool 环境 Debian 8 VirtualBox 配置Debian的源 #163源 deb http://mirrors.163.com/debian/ ...

  3. URL与URI的区别

    URI—Universal Resource Identifier通用资源标志符Web上可用的每种资源如HTML文档.图像.视频片段.程序等都是一个来URI来定位的URI一般由三部组成①访问资源的命名 ...

  4. JQuery中常用的 属性选择器

    jQuery中使用$()作为选择符极大提高工作效率以及方便快捷;一些常用属性的选择器由以下几种 1) $('#id') id选择器 2) $('.class') css选择器,class类名 3) $ ...

  5. 关于为什么RAID5往往掉一个盘后第二个盘也立刻挂掉的原因分析

    很多人遇到过服务器RAID5挂掉,往往掉一个盘后,第二个盘也立刻挂掉. 大家都知道RAID5 一次允许一个盘缺失, RAID 5也是以数据的校验位来保证数据的安全,但它不是以单独硬盘来存放数据的校验位 ...

  6. WPF 获取屏幕分辨率(获取最大宽高)等

    double x = SystemParameters.WorkArea.Width;//得到屏幕工作区域宽度 double y = SystemParameters.WorkArea.Height; ...

  7. RAC RMAN备份

    这篇主要介绍的是RAC 环境下的RMAN 备份. 关于Oracle 备份与恢复的一些理论知识参考我的Blog:       Oracle 备份 与 恢复 概述 http://blog.csdn.net ...

  8. NSURLSessionDataTask

    #import "ViewController.h" @interface ViewController ()<NSURLSessionDelegate,NSURLSessi ...

  9. Uploadify插件使用方法

    1.下载所需文件 2.导入所需文件,还需要应用jquery.js文件 3.导入css.js uploadify.css.jquery.uploadify.min.js 4.前端代码 p标签存放uplo ...

  10. uCgui和emWin的区别

              在国内做嵌入式系统的,开始入门OS的时候,大家应该都会选择uC/OS,为什么?因为代码开源且资料众多嘛.由于uC/OS的原因大家也一定接触了uC/GUI的嵌入式图形软件库.其实uC ...