题目链接

  • 题意:

    给一个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. vim的基本使用方法

    头记:vim作为被大多数程序员所推崇的编辑器,是源于它的自由灵活以及令人舒服的输入模式,但对于新手来说无疑是个噩梦(需要记太多的命令), 而作为使用了vim有一段时间的我来说,总结下常用的命令,以备新 ...

  2. 206.反转单列表 Reverse Linked List

    Reverse a singly linked list. 使用栈 public class Solution { public ListNode ReverseList(ListNode head) ...

  3. iframe 元素

    iframe 元素会创建包含另外一个文档的内联框架(即行内框架). 可以访问:http://www.w3school.com.cn/tags/tag_iframe.asp

  4. Fragment实现底部Tab,切换可保存状态

    activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android& ...

  5. C#进程与线程

    public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { / ...

  6. sealed 密封类,不能被其他类继承,但可以继承其他类

    public sealed class Person:继承类名 { }

  7. centos 安装,配置memcached

    先查看是否已经安装了memcached输入memcached -h会输出memcached版本,或print phpinfo查看: memcached需要libevent支持,没有libevent,就 ...

  8. PHP数组的排序函数

    对保存在数组中的相关数据进行排序是一件非常有意义的事情.在PHP中提供了很多函数可以对数组进行排序,这些函数提供了多种排序的方法.例如,可以通过元素的值或键及自定义排序等. ①简单的数组排序函数简单的 ...

  9. 绘制数据图表的又一利器:C3.js

  10. Hibernate学习笔记--使用ThreadLocal

    参考资料: http://blog.sina.com.cn/s/blog_7ffb8dd5010146i3.html http://lavasoft.blog.51cto.com/62575/5192 ...