题目链接

 #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. poj 1146 ID Codes (字符串处理 生成排列组合 生成当前串的下一个字典序排列 【*模板】 )

    ID Codes Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6229   Accepted: 3737 Descript ...

  2. SpringBoot2.0之整合ActiveMQ(点对点模式)

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  3. BZOJ 1640 [Usaco2007 Nov]Best Cow Line 队列变换:贪心【字典序最小】

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1640 题意: 给你一个长度为n的字符串. 你可以将原串的首字母或尾字母移动到新串的末尾. ...

  4. utf8_general_ci和utf8_unicode_ci的比较

    看到很多数据库的设计对于中文字符都是选择选用utf8_general_ci而非utf8_unicode_ci utf8_general_ci和utf8_unicode_ci的区别并不大:utf8_un ...

  5. MySQL-计算当月重新激活客户_20161013

    13号的草稿 12号的明天补充更新,最近太忙了. 客户留存率是衡量客户价值经常用的指标,可以反映客户的活跃程度,在互联网企业,尤其是现在手机端流量已经超过PC端流量,在安卓和IOS设备上在线时长的数据 ...

  6. hdu3518 Boring Counting[后缀排序]

    裸的统计不同的重复出现子串(不重叠)种数的题.多次使用后缀排序要注意小细节.y数组在重复使用时一定要清空,看那个line25 +k就明白了 ,cnt也要清空,为什么就不说了 #include<b ...

  7. ACM学习历程—FZU 2140 Forever 0.5(计算几何 && 构造)

    Description   Given an integer N, your task is to judge whether there exist N points in the plane su ...

  8. Python基础入门知识

    本节内容 Python介绍 发展史 Python 2 or 3? 安装 Hello World程序 变量 用户输入 模块初识 .pyc是个什么鬼? 数据类型初识 数据运算 表达式if ...else语 ...

  9. CSS 浏览器兼容

    1.  兼容 IF <!--[if lte IE 7]> <style type="text/css"> .menu { position:relative ...

  10. layout属性

    RelativeLayout 第一类:属性值为true可false android:layout_centerHrizontal        水平居中 android:layout_centerVe ...