【HDOJ】1493 QQpet exploratory park】的更多相关文章

超水的动态规划.最后要对概率求Sigma. #include <cstdio> #include <cstring> #include <cstdlib> #define MAXN 61 #define MAXK 11 double dp[MAXK][MAXN]; ]; ] = {, , , , , , , , , }; int main() { int t; int i, j, k, p; #ifndef ONLINE_JUDGE freopen("data…
  A - QQpet exploratory park HDU - 1493 Today, more and more people begin to raise a QQpet. You can get a lot of pleasure from it, although it does not have a real life and it calls for huge patience to take care of it. There is a place called QQpet…
QQpet exploratory park Today, more and more people begin to raise a QQpet. You can get a lot of pleasure from it, although it does not have a real life and it calls for huge patience to take care of it. There is a place called QQpet exploratory park…
题目大意: 一共有61个位置,标记为0~60.其中有10个重要位置,分别为:5, 12, 22, 29, 33, 38, 42, 46, 50 and 55. 有一个筛子,一共6个面,标有1~6.摇到几走几步,开始的位置是在0,一共可以要10次. 输入筛子摇出每个面的概率,输出经过这10个重要位置的概率. 题解: 概率DP问题,定义dp[i][j]为第i次摇筛子,处在位置j处.状态转移方程dp[i][j]=dp[i][j]+dp[i][j-k]*arr[k](1<=k<=6). 位置j处的答案…
其实是求树上的路径间的数据第K大的题目.果断主席树 + LCA.初始流量是这条路径上的最小值.若a<=b,显然直接为s->t建立pipe可以使流量最优:否则,对[0, 10**4]二分得到boundry,使得boundry * n_edge - sum_edge <= k/b, 或者建立s->t,然后不断extend s->t. /* 4729 */ #include <iostream> #include <sstream> #include <…
DP/四边形不等式 裸题环形石子合并…… 拆环为链即可 //HDOJ 3506 #include<cmath> #include<vector> #include<cstdio> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> #define rep(i,n) for(int i=0;i<n;++i) #define…
DP/四边形不等式 这题跟石子合并有点像…… dp[i][j]为将第 i 个点开始的 j 个点合并的最小代价. 易知有 dp[i][j]=min{dp[i][j] , dp[i][k-i+1]+dp[k+1][j-(k-i+1)]+w(i,k,j)} (这个地方一开始写错了……) 即,将一棵树从k处断开成(i,k)和(k+1,i+j-1)两棵树,再加上将两棵树连起来的两条树枝的长度w(i,k,j) 其中,$ w(i,k,j)=x[k+1]-x[i]+y[k]-y[i+j-1] $ 那么根据四边形…
DP/四边形不等式 要求将一个可重集S分成M个子集,求子集的极差的平方和最小是多少…… 首先我们先将这N个数排序,容易想到每个自己都对应着这个有序数组中的一段……而不会是互相穿插着= =因为交换一下明显可以减小极差 然后……直接四边形不等式上吧……这应该不用证明了吧? MLE了一次:这次的w函数不能再开数组去存了……会爆的,直接算就行了= =反正是知道下标直接就能乘出来. 数据比较弱,我没开long long保存中间结果居然也没爆……(只保证最后结果不会爆int,没说DP过程中不会……) //H…
DP/四边形不等式 做过POJ 1739 邮局那道题后就很容易写出动规方程: dp[i][j]=min{dp[i-1][k]+w[k+1][j]}(表示前 j 个点分成 i 块的最小代价) $w(l,r)=\sum_{i=l}^{r}\sum_{j=i+1}^{r}a[i]*a[j]$ 那么就有 $w(l,r+1)=w(l,r)+a[j]*\sum\limits_{i=l}^{r}a[i]$ 所以:w[i][j]明显满足 关于区间包含的单调性 然后我们大胆猜想,小(bu)心(yong)证明,w[…
DP/单调队列优化 呃……环形链求最大k子段和. 首先拆环为链求前缀和…… 然后单调队列吧<_<,裸题没啥好说的…… WA:为毛手写队列就会挂,必须用STL的deque?(写挂自己弱……sigh) //HDOJ 3415 #include<queue> #include<cmath> #include<vector> #include<cstdio> #include<cstring> #include<cstdlib>…