Domination
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll read(){
int x = , f = ; char ch = getchar();
while(ch > '' || ch < ''){if (ch == '-') f = -; ch = getchar();}
while(ch >= '' && ch <= ''){ x = x*+ch-''; ch = getchar();}
return x*f;
} /************************************************************************/ const int maxn = ;
int n, m;
double dp[maxn*maxn*][maxn][maxn]; int main(){
int t;
t = read();
while(t--){
n = read(); m = read();
memset(dp, , sizeof(dp));
dp[][][] = ;
for(int i = ;i <= n*m;i++){
for(int j = ;j <= n;j++){
for(int k = ;k <= m;k++){
if(dp[i][j][k]){
dp[i+][j+][k] += dp[i][j][k] * (n-j)*k/(1.0*(n*m-i));
dp[i+][j][k+] += dp[i][j][k] * (m-k)*j/(1.0*(n*m-i));
dp[i+][j+][k+] += dp[i][j][k] * (n-j)*(m-k)/(1.0*(n*m-i));
if(j < n || k < m)
dp[i+][j][k] += dp[i][j][k] * (j*k-i)/(1.0*(n*m-i));
}
}
}
}
double ans = 0.0;
for(int i = ;i <= n*m;i++){
ans += dp[i][n][m]*i;
}
printf("%.12lf\n", ans);
}
return ;
}
Domination的更多相关文章
- 2014牡丹江D Domination
Domination Time Limit: 8 Seconds Memory Limit: 131072 KB Special Judge Edward is the headm ...
- zoj3822 Domination(概率dp)
Domination Time Limit: 8 Seconds Memory Limit: 131072 KB Special Judge Edward is the headm ...
- ZOJ 3822 Domination 期望dp
Domination Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.zju.edu.cn/onlinejudge/showProblem ...
- zoj 3822 Domination (可能性DP)
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 ...
- ZOJ3822 ACM-ICPC 2014 亚洲杯赛事现场牡丹江司D称号Domination 可能性DP
Domination Time Limit: 8 Seconds Memory Limit: 131072 KB Special Judge Edward is the headm ...
- zoj 3822 Domination(dp)
题目链接:zoj 3822 Domination 题目大意:给定一个N∗M的棋盘,每次任选一个位置放置一枚棋子,直到每行每列上都至少有一枚棋子,问放置棋子个数的期望. 解题思路:大白书上概率那一张有一 ...
- Domination(概率DP)
Domination 题目链接:https://odzkskevi.qnssl.com/9713ae1d3ff2cc043442f25e9a86814c?v=1531624384 Edward is ...
- ZOJ 3822 Domination 概率dp 难度:0
Domination Time Limit: 8 Seconds Memory Limit: 131072 KB Special Judge Edward is the headm ...
- ZOJ 3822 Domination (三维概率DP)
E - Domination Time Limit:8000MS Memory Limit:131072KB 64bit IO Format:%lld & %llu Submi ...
随机推荐
- Strom 消息处理机制 中英对照翻译 (Storm如何保证消息被完全处理)
官方链接: http://storm.incubator.apache.org/documentation/Guaranteeing-message-processing.html What does ...
- Trustzone——利用硬件对数据加密,秘钥存在芯片里
我是看 https://zhuanlan.zhihu.com/p/26441212 这个文章知道trustzone自身会存储秘钥,这个秘钥可以来自用户指纹,也可以来自云端下发的key. Truztzo ...
- 线程绑定CPU核-sched_setaffinity
CPU亲合力就是指在Linux系统中能够将一个或多个进程绑定到一个或多个处理器上运行. 一个进程的CPU亲合力掩码决定了该进程将在哪个或哪几个CPU上运行.在一个多处理器系统中,设置CPU亲合力的掩码 ...
- DLL进一步讲解:extern "C" __declspec(dllexport)
一.__declspec(dllexport): 将一个函数声名为导出函数,就是说这个函数要被其他程序调用,即作为DLL的一个对外函数接口. 通常它和extern "C" ...
- xxx referenced from: xxx in xxx.o
情形一:可能是有一些源码文件没有加入工程所导致的,找到相应的.h和.m文件,将其add进入项目工程即可解决这种问题. 情形二:也有可能是某些framework没有加入项目中, 示例: Undefi ...
- BZOJ3524:[POI2014]Couriers
浅谈主席树:https://www.cnblogs.com/AKMer/p/9956734.html 题目传送门:https://www.lydsy.com/JudgeOnline/problem.p ...
- BZOJ2467五角形生成树——数学
题目:http://www.lydsy.com/JudgeOnline/problem.php?id=2467 可以得出只需在每个五角形中去掉任意一条边,在某个五角形中去掉包括内边的两条边即可. 代码 ...
- C#设计模式(5)——建造者模式
一.概念 建造者模式将一个复杂对象的构建与表示分离,使得同样的构建过程可以创建不同的表示. 二.模型 三.代码实现 /// <summary> /// 建造者模式的演变 /// 省略了指挥 ...
- 【249】◀▶IEW-Unit14
Unit 14 Money and Finance 线图写作技巧 1.Model1对应图片分析 The graph contains information about the price in US ...
- POJ-3262
Protecting the Flowers Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7923 Accepted: ...