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 ...
随机推荐
- Exception of type 'System.OutOfMemoryException' was thrown
最近刚换了服务器,开始测试的时候未发现什么问题,可是一旦同一时间段操作的人比较多的时候,就会抛出如下错误: Server Error in '/' Application. Exception of ...
- Android环境下通过C框架层控制WIFI【转】
本文转载自:https://blog.csdn.net/edw200/article/details/52192631 本人是从事Linux嵌入式开发的,安卓wifi控制在安卓JAVA层已经做得非常成 ...
- 吴恩达机器学习笔记(十二) —— Application Example: Photo OCR(完)
主要内容: 一.Photo OCR 二.Getting lots of data:artificial data synthesis 三.Ceiling analysis 一.Photo OCR Ph ...
- pycharm解决Inconsistent indentation:mix of tabs and spaces
- RQNOJ 311 [NOIP2000]乘积最大:划分型dp
题目链接:https://www.rqnoj.cn/problem/311 题意: 给你一个长度为n的数字,用t个乘号分开,问你分开后乘积最大为多少.(6<=n<=40,1<=k&l ...
- 使用js获取当前页面的url网址信息。
1.设置或获取整个 URL 为字符串: window.location.href 2.设置或获取与 URL 关联的端口号码: window.location.port 3.设置或获取 URL 的协议部 ...
- codeforces 660B B. Seating On Bus(模拟)
题目链接: B. Seating On Bus time limit per test 1 second memory limit per test 256 megabytes input stand ...
- JDK中主要的包介绍
- CSS实现简单无缝滚动
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- CodeForces - 1000D:Yet Another Problem On a Subsequence (DP+组合数)
The sequence of integers a1,a2,…,aka1,a2,…,ak is called a good array if a1=k−1a1=k−1 and a1>0a1&g ...