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 思路:题目的意思是求树上的两点,使得树上其余的点到其中一个点的 ...
随机推荐
- SpringMvc之@RequestParam详解
@RequestParam是传递参数的. @RequestParam用于将请求参数区数据映射到功能处理方法的参数上. public String queryUserName(@RequestParam ...
- python 下的数据结构与算法---1:让一切从无关开始
这段时间把<Data Structure and Algorithms with python>以及<Problem Solving with Algorithms and Dat ...
- AngularJs练习Demo13Provider_factory
@{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="viewport&quo ...
- jQuery操作元素
通常,我们在创建元素时,会使用以下代码: var p = document.createElement("p"); p.innerText = "this is para ...
- js动态加载html,加载后的页面元素某些事件失效的解决方案
用 live 来绑定 例如: $("#items li .addToCartimg").live("click",function(){ $('.popDeta ...
- SVG基础
可缩放矢量图形(Scalable Vector Graphics)是基于可扩展标记语言(标准通用标记语言的子集),用于描述二维矢量图形的一种图形格式.它由万维网联盟制定,是一个开放标准.SVG 是使用 ...
- WEB开发中常用的正则表达式
在计算机科学中,正则表达式用来描述或者匹配一系列符合某个句法规则的字符串的单个字符串.在WEB开发中,正则表达式通常用来检测.查找替换某些符合规则的字符串,如检测用户输入E-mai格式是否正确,采集符 ...
- cygwin编译SDL1.2
1.下载了一个SDL-1.2.14.tar.gz 2.下载一个cygwin64对SDL-1.2.14.tar.gz解压 tar -zxvf SDL-1.2.14.tar.gz 在网上找的大概是需要需要 ...
- tbschedule
tbschedule 此文档内部包括:1.设计目标说明2.主要概念解释3.涉及的数据对象说明4.涉及的业务接口说明5.Sleep模式和NotSleep模式的区别6.使用过程中的注意事项 1.调度器的设 ...
- qt实现头像上传功能(写了4个类,朝十晚八的博客,非常好)
想必大家都使用过qt的自定义头像功能吧,那么图1应该不会陌生,本片文章我就是要模拟一个这样的功能,虽然没有这么强大的效果,但是能够满足一定的需求. 图1 qq上传图片 首先在讲解功能之前,我先给出一片 ...