zoj 3822 Domination 概率dp
来源:互联网 发布:特战先驱 知乎 编辑:程序博客网 时间:2024/06/06 02:09
#include<iostream>#include<cstring>#include<cstdio>using namespace std;int T;int l,c;double dp[2605][55][55];bool b[2605][55][55];double DP(int k,int x,int y){ if(x>=l&&y>=c)return 0; if(b[k][x][y])return dp[k][x][y]; if(x==0||y==0)return DP(k+1,x+1,y+1)+1; int st = x*y-k;int lst = l*c-k;int las = (l-x)*(c-y); double ans = 0; //if(lst==0)return 0; if(k<x*y)ans += DP(k+1,x,y)*(st/(1.0*lst)); if(x<l)ans+=(l-x)*y/(1.0*lst)*DP(k+1,x+1,y); if(y<c)ans+=(c-y)*x/(1.0*lst)*DP(k+1,x,y+1); if(x<l&&y<c)ans+=las/(1.0*lst)*DP(k+1,x+1,y+1); b[k][x][y]=1; return dp[k][x][y] = ans+1;}int main(){ scanf("%d",&T); while(T--){ memset(dp,0,sizeof(dp));memset(b,0,sizeof(b)); scanf("%d%d",&l,&c); printf("%.12lf\n",DP(0,0,0)); }}
0 0
- [概率dp] zoj 3822 Domination
- ZOJ 3822 Domination(概率dp)
- [概率dp] ZOJ 3822 Domination
- ZOJ 3822 Domination(概率dp)
- ZOJ 3822 Domination 概率DP
- zoj 3822 Domination 概率dp
- zoj 3822 Domination (概率DP)
- ZOJ - 3822 Domination(概率dp)
- ZOJ 3822 Domination 概率DP
- zoj 3822 Domination 概率dp
- ZOJ 3822 Domination [概率DP]
- zoj 3822 Domination 概率DP
- ZOJ 3822Domination(概率DP)
- ZOJ 3822 Domination(概率DP)
- ZOJ 3822 Domination【概率DP】
- ZOJ 3822 Domination【概率dp】
- -----概率DP ZOJ 3822- Domination
- ZOJ 3822 Domination (概率DP)
- 获取HttpURLConnection 响应体内容
- scp命令行拷贝
- 使用lua++.exe的方法
- Android端通过httpCilent访问Tomcat服务器servlet
- 斗地主的智慧你我共享
- zoj 3822 Domination 概率dp
- 为什么要用补码
- 关于android中进程,服务和线程的一些理解
- Java包装类
- 学习Python第五天
- ios-day02-04(图片浏览器)
- mysql 远程连接的那些事
- 帧差法、光流法、背景减除法
- 对某音频库.Net API库文件的破解