题目链接

 #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的更多相关文章

  1. 2014牡丹江D Domination

    Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headm ...

  2. zoj3822 Domination(概率dp)

    Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headm ...

  3. ZOJ 3822 Domination 期望dp

    Domination Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.zju.edu.cn/onlinejudge/showProblem ...

  4. zoj 3822 Domination (可能性DP)

    Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headm ...

  5. zoj 3822 Domination(2014牡丹江区域赛D称号)

    Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headm ...

  6. ZOJ3822 ACM-ICPC 2014 亚洲杯赛事现场牡丹江司D称号Domination 可能性DP

    Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headm ...

  7. zoj 3822 Domination(dp)

    题目链接:zoj 3822 Domination 题目大意:给定一个N∗M的棋盘,每次任选一个位置放置一枚棋子,直到每行每列上都至少有一枚棋子,问放置棋子个数的期望. 解题思路:大白书上概率那一张有一 ...

  8. Domination(概率DP)

    Domination 题目链接:https://odzkskevi.qnssl.com/9713ae1d3ff2cc043442f25e9a86814c?v=1531624384 Edward is ...

  9. ZOJ 3822 Domination 概率dp 难度:0

    Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headm ...

  10. ZOJ 3822 Domination (三维概率DP)

    E - Domination Time Limit:8000MS     Memory Limit:131072KB     64bit IO Format:%lld & %llu Submi ...

随机推荐

  1. BZOJ 3410 [Usaco2009 Dec]Selfish Grazing 自私的食草者:贪心【最多线段覆盖】

    题目链接:http://begin.lydsy.com/JudgeOnline/problem.php?id=1324 题意: 给你n个区间,问你最多能选择多少个区间使得它们不相互覆盖. 题解: RQ ...

  2. kvm初体验之七:attach usb storage device to a VM

    1. virsh attach-disk vm1 /dev/sdb sdc 将host上的/dev/sdb挂载到vm1的/dev/sdc上 2. virsh detach-disk vm1 sdc 将 ...

  3. kvm初体验之一:参考文档

    KVM Virtualization in RHEL 6 Made Easy KVM Virtualization in RHEL 6 Made Easy – Part 2 RHEL 6 Virtua ...

  4. 使用谷歌浏览器进行Web开发技巧

    1.为了避免缓存影响开发,使用使用那个“Ctrl+Shift+N”进入浏览器的隐身模式

  5. VC++动态链接库(DLL)编程深入浅出:Q&A(原创)

    Q1:extern “C” 是做什么用的? A1:一种情况是多个文件中,变量声明或者函数声明,需要extern “C”,这种情况在这里不做讨论. 在dll工程中,被extern "C&quo ...

  6. shell命令自动分区提示

    echo  ’n p 1 +20M w’ | fdisk /dev/sda

  7. 洛谷P3252 [JLOI2012]树

    题目描述 在这个问题中,给定一个值S和一棵树.在树的每个节点有一个正整数,问有多少条路径的节点总和达到S.路径中节点的深度必须是升序的.假设节点1是根节点,根的深度是0,它的儿子节点的深度为1.路径不 ...

  8. RT-Thread信号量使用(动态/静态信号量) 及 信号量的四种使用场合

    信号量(Semaphore),有时被称为信号灯,是在多线程环境下使用的一种设施,是可以用来保证两个或多个关键代码段不被并发调用.在进入一个关键代码段之前,线程必须获取一个信号量:一旦该关键代码段完成了 ...

  9. Python3解leetcode Single Number

    问题描述: Given a non-empty array of integers, every element appears twice except for one. Find that sin ...

  10. 怎么在docker容器的mysql的编码格式变为utf8

    第一个方法: 1.  编辑MySql的配置文件 MySql的配置文件Windows下一般在系统目录下或者在MySql的安装目录下名字叫my.ini,可以搜索,Linux下一般是/etc/my.cnf ...