【DP】ZOJ 3605 Find the Marble
来源:互联网 发布:淘宝咸鱼电话 编辑:程序博客网 时间:2024/05/22 21:52
点击打开链接
题意:
N个杯子,开始小球在第S个杯子中,
M次 杯子互换,但是只看到了K次互换,问小球最后在哪个杯子的概率最大
三维记录:第几次互换,第几次看到,球的位置
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;#define ll long longll t,n,m,k,d,a[111],b[111],dp[55][55][55];int main(){ cin>>t; while(t--) { cin>>n>>m>>k>>d; for(int i=1;i<=m;i++) cin>>a[i]>>b[i]; memset(dp,0,sizeof(dp)); for(int i=0;i<=m;i++) dp[i][0][d]=1; for(int i=1;i<=m;i++)//m { for(int j=1;j<=i&&j<=k;j++)//枚举k { dp[i][j][a[i]]+=dp[i-1][j-1][b[i]];//看到 dp[i][j][b[i]]+=dp[i-1][j-1][a[i]]; for(int l=1;l<=n;l++)//没看到 { dp[i][j][l]+=dp[i-1][j][l]; if(l!=a[i]&&l!=b[i]) dp[i][j][l]+=dp[i-1][j-1][l]; } } } ll Max=0,p; for(int i=1;i<=n;i++) { if(Max<dp[m][k][i]) Max=dp[m][k][i],p=i; } cout<<p<<endl; } return 0;}
0 0
- ZOJ 3605 Find the Marble(三维dp)
- ZOJ 3605 Find the Marble(DP)
- zoj 3605 Find the Marble 计数dp
- zoj 3605 Find the Marble (概率dp)
- 【DP】ZOJ 3605 Find the Marble
- ZOJ 3605 Find the Marble(dp)
- ZOJ 3605-F - Find the Marble-DP
- zoj 3605 Find the Marble (dp)
- ZOJ 3605Find the Marble
- ZOJ 3605 Find the Marble
- ZOJ 3605Find the Marble
- ZOJ 3605 Find the Marble
- ZOJ 3605 Find the Marble(dp啊 三维)
- Find the Marble ZOJ
- ZOJ3605-Find the Marble(概率DP)
- zoj3605 Find the Marble --- 概率dp
- ZOj3605--- Find the Marble(概率dp)
- zoj3605 Find the Marble(三维dp)
- 设计模式之一 简单工厂模式
- [LeetCode]202.Happy Number
- 以四个在读写器作用范围内的电子标签为例说明二进制树型搜索算法选择电子标签的迭代过程
- Marriage Match II (hdu 3081 二分图+并查集)
- 记录一下今儿的java笔试题编程
- 【DP】ZOJ 3605 Find the Marble
- Viva Confetti(几何+圆盘覆盖问题)
- jQuery设置判断一组chechbox的checked属性
- 模拟一个简单的时钟
- Delegate
- 1~100之间 7的倍数的个数。并打印
- Service之“绑定”
- 纠删码与分布式系统
- Eigen中的变换矩阵