zoj 3329 概率dp】的更多相关文章

题意:有三个骰子,分别有k1,k2,k3个面.每个面值为1--kn每次掷骰子,如果三个面分别为a,b,c则分数置0,否则加上三个骰子的分数之和.当分数大于n时结束.求游戏的期望步数.初始分数为0 链接:点我设dp[i]表示达到i分时到达目标状态的期望,pk为投掷k分的概率,p0为回到0的概率则dp[i]=∑(pk*dp[i+k])+dp[0]*p0+1;都和dp[0]有关系,而且dp[0]就是我们所求,为常数设dp[i]=A[i]*dp[0]+B[i];代入上述方程右边得到:dp[i]=∑(pk…
One Person Game Time Limit: 1 Second      Memory Limit: 32768 KB      Special Judge There is a very simple and interesting one-person game. You have 3 dice, namely Die1, Die2 and Die3. Die1 has K1 faces. Die2 has K2 faces. Die3 has K3 faces. All the…
题意:一只吸血鬼,有n条路给他走,每次他随机走一条路,每条路有个限制,如果当时这个吸血鬼的攻击力大于等于某个值,那么就会花费t天逃出去,否则,花费1天的时间,并且攻击力增加,问他逃出去的期望 用记忆化搜索做,很好理解. #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<queue> #in…
/* 题目大意:一个n*m的棋盘,每天放一个棋子,每行每列至少有一个棋子时结束.求达到每行每列至少有一个棋子的天数的数学期望. */ #include <iostream> #include <cstdio> #include <cstring> using namespace std; ; double dp[maxn*maxn][maxn][maxn];//放i颗棋子,j行有棋子,k列有棋子 int main() { int t,n,m,i,j,k; scanf(&…
题目大意: 给定3个已经规定好k1,k2,k3面的3个色子,如果扔到a,b,c则重新开始从1 计数,否则不断叠加所有面的数字之和,直到超过n,输出丢的次数的数学期望 我们在此令dp[]数组记录从当前数值到结束的数学期望 假如有3个面数都为2的色子 那么dp[i] = 1.0 / 2/2/2 * dp[0] + 1.0/8*dp[i+3] +3.0/8*dp[i+4]+3.0/8*dp[i+5]+1.0/8*dp[i+6] + 1 当然那些下标大于i的dp值均为0 可是我们这样从后往前推会导致无法…
poj 2096 题目:http://poj.org/problem?id=2096 f[ i ][ j ] 表示收集了 i 个 n 的那个. j 个 s 的那个的期望步数. #include<cstdio> #include<cstring> #include<algorithm> #define db double using namespace std; ; db n,s,f[N][N]; int main() { scanf("%lf%lf"…
ZOJ Problem Set - 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 chess with his friends. What's more, he bought a lar…
题目链接 参考博客:http://blog.csdn.net/napoleon_acm/article/details/40020297 题意:给定n*m的空棋盘 每一次在上面选择一个空的位置放置一枚棋子,直至每一行每一列都至少有一个棋子,求放置次数的期望 分析: dp[i][j][k] 表示当前用了<=k个chess ,覆盖了i行j列(i*j的格子 每行至少一个,每列至少一个)的概率. dp[i][j][k] 由 dp[i][j][k-1] , dp[i-1][j][k-1], dp[i][j…
记忆化搜索+概率DP 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include<iomanip> #include<cmath> #include<cstring> #include<vector> #define ll __int64 #define pi acos(-1.0) #define MAX 50000 using names…
题目链接:problemId=5376">http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5376 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 ch…