题目链接

  • 题意:

    给一个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. mybati之day02

    今天开始讲解mybatis的第二天内容  一,拼接sql 在mapper.xml中,会多次使用到同一条sql片段,这时为了简便书写,将其定义出来 <sql id="base_sql&q ...

  2. Java初转型-Maven入门

    原系列名:Maven学习总结(一) 原博文出自于:http://www.cnblogs.com/xdp-gacl/p/3498271.html 感谢! 一.Maven的基本概念 Maven(翻译为&q ...

  3. C#之out与ref的共性与区别以及用法

    引入: 首先看一个例子: class Program { static void Main(string[] args) { ; int result = Test(number); Console. ...

  4. C#基础静态类的设计

  5. FineUI 点击按钮添加标签页

    <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat=&quo ...

  6. Visual Studio Code使用typings拓展自动补全功能

    转自:http://blog.csdn.net/liyijun4114/article/details/51658087 参考来源: 官方介绍: https://code.visualstudio.c ...

  7. shell获取文件行数

    获取文件行数: echo `cat $file | wc -l` 获取文件中不重复的行数(去重后) echo `awk '{$1="";print $0;}' $file_tel ...

  8. spring 学习 AOP和IOC

    自11开始接触三大框架,至今已俞5载, 当时风光无限的ssh,现在还在被广泛使用,并有扩大之势的只有spring了 spring主要特性,是广为使用的AOP(面向切面)和IOC(控制反转) 1.其中, ...

  9. 同步关键字synchronized

    同步关键字synchronized 同步关键字synchronized使用简洁,代码可维护性好.在JDK6中,性能也比早期的JDK有很大的改进.如果可以满足程序要求,应该首先考虑这种同步方式. 关键字 ...

  10. JS判断手机端和PC端自动跳转

    <script type="text/javascript">     function browserRedirect() {     var sUserAgent ...