ZOJ 3822 可能性DP

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3822

本场比赛之前,我记得。见WALK概率路DP称号。那么它应该是可以考虑的概率DP,十一还特意看了碍着,

当场景。真的OUT了。然后好激动的样子,開始推得二维。然后感觉好难推。发现n仅仅有50。所以就去推三维,然后发现k<max(i,j)的时候,有无用状态,无用状态初始化不会处理,然后认为好像也用不到,可是感觉更稳的还是去推二维,然后就陷入二维--------悲剧了  最后打铁,真他妈不爽

也发现了自己的问题:1、平时学的东西掌握的不够扎实

2、事实上假设队友没明确自己的意思,全然自己推吧,自信点,别想着必须队友确认才去做

想要保研牛校或者出国。单单小的竞赛还是不够的,ACM假设不出结果会有非常大压力。预计保牛校无望,我校牛逼的学长学姐。也就是清华或者交大的硕博连读或者博士,这对于92年出生的我实在不能忍......

还有西安一站,这几天我会全力最后一搏,下次比赛绝不犯此次比赛的错误。假设自己的思路队友这边难以沟通,必要的话,就自己坚持自己想自己做,尤其自信点,有非常多人事实上不像他们想象的那样强,我自己也不想我想的那么弱

E[i][j][k]  已经占领i行j列。走了k步的时候,还须要走的步数的期望。其它看代码就好

#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define CL(a,b) memset(a,b,sizeof(a))
#define IN(s) freopen(s,"r",stdin)
const int MAXN = 55;
double dp[MAXN][MAXN][MAXN*MAXN];

int main()
{
    //IN("D.txt");
    int ncase;
    scanf("%d",&ncase);
    int n,m;
    while(ncase--)
    {
        scanf("%d%d",&n,&m);
        CL(dp,0);
        for(int i=n;i>=0;i--)
            for(int j=m;j>=0;j--)
            {
                if(i==n&&j==m)continue;
                for(int k=i*j;k>=max(i,j);k--)
                {
                    dp[i][j][k]+=1.0*j*(n-i)/(1.0*n*m-k)*dp[i+1][j][k+1];
                    dp[i][j][k]+=1.0*i*(m-j)/(1.0*n*m-k)*dp[i][j+1][k+1];
                    dp[i][j][k]+=1.0*(i*j-k)/(1.0*n*m-k)*dp[i][j][k+1];
                    dp[i][j][k]+=1.0*(n-i)*(m-j)/(1.0*n*m-k)*dp[i+1][j+1][k+1];
                    dp[i][j][k]+=1.0;
                }
            }
        printf("%.12lf\n",dp[0][0][0]);
    }
    return 0;
}

版权声明:本文博客原创文章,博客,未经同意,不得转载。

时间: 2024-10-05 05:32:39

ZOJ 3822 可能性DP的相关文章

zoj 3822概率dp

Domination Time Limit: 8 Seconds Memory Limit: 131072 KB Special Judge Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. What's more, he bought a large decorative chessboard with N r

zoj 3822 概率dp

1 /* 2 题目大意:一个n*m的棋盘,每天放一个棋子,每行每列至少有一个棋子时结束.求达到每行每列至少有一个棋子的天数的数学期望. 3 */ 4 #include <iostream> 5 #include <cstdio> 6 #include <cstring> 7 using namespace std; 8 9 const int maxn=55; 10 double dp[maxn*maxn][maxn][maxn];//放i颗棋子,j行有棋子,k列有棋子

ZOJ 3822 Domination DP

状态i,j,k为已经有i行,j列放满,放了k个棋子的概率,转移分四种情况(只增加行,只增加列,行列都增加,行列都不增加)讨论即可. #include <cstdio> #include <cstring> #include <algorithm> #include <queue> #include <stack> #include <map> #include <set> #include <climits>

zoj 3640 概率dp

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4808 Background     If thou doest well, shalt thou not be accepted? and if thou doest not well, sin lieth at the door. And unto thee shall be his desire, and thou shalt rule over him. And Cai

ZOJ 1093 &amp;&amp; NYoj16(DP)

~~~~ 两个题目大致类似,NYOJ上面那道题就是小白上的矩形嵌套啦. 都是先对长宽进行排序,然后逐层更新最大值(边更新边记录). 好了,不说了. 题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1093 http://acm.nyist.net/JudgeOnline/problem.php?pid=16 ~~~~ ZOJ1093: #include<cstdio> #include<cstring&

zoj 3299 概率dp

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3329 回头重推式子 题解:http://blog.csdn.net/morgan_xww/article/details/6775853#reply 学到: 1.目前做的两道期望的状态转移方程都是从大向小推,定义方式:dp[i][j][k]....  满足i,j,k时,要达到upbound(i),upbound(j),upbound(k),需要XX的期望 2.待定系数的方

[概率dp] zoj 3822 Domination

题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3822 Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays che

ZOJ 3822 Domination (三维概率DP)

E - Domination Time Limit:8000MS     Memory Limit:131072KB     64bit IO Format:%lld & %llu Submit Status Description Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. What's more, he

ZOJ 3822 Domination (概率DP)

Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. What's more, he bought a large decorative chessboar