2014牡丹江——Domination
- 题意:
给一个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的更多相关文章
- 2014牡丹江D Domination
Domination Time Limit: 8 Seconds Memory Limit: 131072 KB Special Judge Edward is the headm ...
- zoj 3822 Domination(2014牡丹江区域赛D称号)
Domination Time Limit: 8 Seconds Memory Limit: 131072 KB Special Judge Edward is the headm ...
- zoj 3822 Domination(2014牡丹江区域赛D题) (概率dp)
3799567 2014-10-14 10:13:59 Acce ...
- zoj 3822 Domination 概率dp 2014牡丹江站D题
Domination Time Limit: 8 Seconds Memory Limit: 131072 KB Special Judge Edward is the headm ...
- ACM学习历程——ZOJ 3822 Domination (2014牡丹江区域赛 D题)(概率,数学递推)
Description Edward is the headmaster of Marjar University. He is enthusiastic about chess and often ...
- 2014 牡丹江区域赛 B D I
http://acm.zju.edu.cn/onlinejudge/showContestProblems.do?contestId=358 The 2014 ACM-ICPC Asia Mudanj ...
- ZOJ 3829 Known Notation (2014牡丹江H称号)
主题链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do? problemId=5383 Known Notation Time Limit: 2 S ...
- The 2014 ACM-ICPC Asia Mudanjiang Regional Contest(2014牡丹江区域赛)
The 2014 ACM-ICPC Asia Mudanjiang Regional Contest 题目链接 没去现场.做的网络同步赛.感觉还能够,搞了6题 A:这是签到题,对于A堆除掉.假设没剩余 ...
- zoj 3820(2014牡丹江现场赛B题)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5374 思路:题目的意思是求树上的两点,使得树上其余的点到其中一个点的 ...
随机推荐
- C#位移运算符
代码如下: /// <summary> /// 位移运算符"<<"左位移运算符,">>"右位移运算符 /// 在进行位移运算 ...
- netstat 命令详解
netstat命令是一个监控TCP/IP网络的非常有用的工具,它可以显示路由表.实际的网络连接以及每一个网络接口设备的状态信息,在我的计算机上执行netstat后,其输出结果为:netstat命令是一 ...
- inode-软链接与硬链接
一.inode是什么?理解inode,要从文件储存说起.文件储存在硬盘上,硬盘的最小存储单位叫做"扇区"(Sector).每个扇区储存512字节(相当于0.5KB).操作系统读取硬 ...
- 新手们的GDI+绘制方格
//绘制panel控件触发的事件 //不可在窗体加载时绘制方格 private void panel1_Paint(object sender, PaintEventArgs e) ...
- 32位PLSQL_Developer连接oracle11g_64位
1. 请将你下载的instantclient-basic-win32-10.2.0.5 文件解压.然后复制到你的数据库安装的文件夹下的producti文件夹下,我的是: E:\app\Administ ...
- js 日期控件 可以显示为和历
日期控件的js <!-- /** * Calendar * @param beginYear 1990 * @param endYear 2010 * @param language 0(zh_ ...
- C# 前台线程与后台线程区别
using System; using System.Drawing; using System.Windows.Forms; using System.Threading; namespace Wi ...
- C/C++中逗号表达式的用法
代码: #include <cstdio> #include <iostream> using namespace std; int main(){ int t1,t2; t1 ...
- (转)OS X 升級後 MacPorts 重新安裝筆記
原地址:http://blog.lyhdev.com/2012/07/os-x-macports.html Mac OS X 10.8 Mountain Lion 正式發佈,而且祭出台幣 $590 元 ...
- AFC项目开发文档整理
AFC项目开发文档整理 PHPCMS 的确是一个伟大的CMS,我对它爱不释手. 标签嵌套无法loop获取的解决办法.关键代码如下: /\*后台添加\*/ $str = preg_replace ( & ...