
##动态规划
文章平均质量分 77
GDRetop
数据研发专家,ETL工程师
展开
-
编程之美:第一章游戏之乐-饮料供货问题
书中已经提到了用背包方法解,复杂度为V*N*max(C),空间复杂度为O(v)这里想了一些其它方法以及谈谈书中提到的贪心算法方法1: 采用单调队列优化复杂度为O(V*n),空间为2*V单调队列优化方法参考背包九讲。是可以实现的。但n很大的时候,就不是很好了方法2:二进制表示法优化复杂度O(V*N*log(C)),空间为V同样参考背包九讲,对C分解成1,2,4,8原创 2017-08-17 19:20:32 · 490 阅读 · 0 评论 -
hdu 5303 Delicious Apples 2015多校联合训练赛2 dp+枚举
Delicious ApplesTime Limit: 5000/3000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 311 Accepted Submission(s): 92Problem DescriptionThere are原创 2015-07-24 10:16:33 · 649 阅读 · 0 评论 -
hdu 5291 Candy Distribution 2015 Multi-University Training Contest 1 树形dp,
Candy DistributionTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 217 Accepted Submission(s): 73Problem DescriptionWY has n k原创 2015-07-23 11:59:30 · 1122 阅读 · 1 评论 -
hdu 5282 Senior's String动态规划
题目:x,y两个串,求x有多少个子序列在y的子序列中出现,且x的子序列满足长度为x和y最长子序列的长度用dp[i][j]表示x的i位置和y的j位置的最长公共子序列长度。求出dp[i][j]然后num[i][j]表示x的前i个字符构成的长度为dp[i][j]的子序列中,有多少个出现在y前j个字符构成的长度为dp[i][j]的子序列里。如果dp[i][j] == dp[i-1][1原创 2015-07-21 10:38:59 · 662 阅读 · 0 评论 -
zoj 3329 One Person Game 动态规划,迭代法,二分
题意:给三个骰子,骰子有k1,k2,k3个面。每次掷骰子,得到的点数和为前进的步数,如果掷骰子的结果为c1,c2,c3(有序)则回到原点。从0点出发,到达大于N的点,则游戏结束。求掷骰子次数的期望。转移方程为: dp[i] = dp[i+l1+l2+l3]*(1/k1/k2/k3)+dp[0]*(1/k1/k2/k3)+1其中枚举l1,l2,l3为掷骰子得原创 2015-07-20 18:03:15 · 825 阅读 · 0 评论 -
hdu 4539 郑厂长系列故事——排兵布阵 插头dp
网上多是一行一行处理的,其实因为距离为2,可以把图分为奇数点和偶数点,分成两张图,这两张图的点互不影响用插头dp dp[i][j] 表示前i个点能到达j的状态,判断i+1个点时根据这个点是否能放士兵,以及上方位置,左上方位置,右上方位置,左方位置有无士兵来决定这个位置是否可以放置士兵。奇偶图分别dp,每次dp复杂度 = (n*m*2^m) 因为有效的状态并不多(170), 还可以删除一些无用原创 2014-12-03 18:42:47 · 934 阅读 · 0 评论 -
hdu 4293 Groups dp
GroupsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1282 Accepted Submission(s): 493Problem Description After the regional原创 2014-12-02 11:33:03 · 620 阅读 · 0 评论 -
hdu 4737 A Bit Fun o(30*n)
A Bit FunTime Limit: 5000/2500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2092 Accepted Submission(s): 1040Problem DescriptionThere are n numb原创 2014-11-07 19:47:33 · 753 阅读 · 0 评论 -
hdu 4949 Light 插头dp
LightTime Limit: 18000/9000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 105 Accepted Submission(s): 42Problem DescriptionTeacher Mai has a board of原创 2014-08-21 11:11:27 · 1278 阅读 · 0 评论 -
hdu Stupid Tower Defense 4939 dp
#include#include#includeusing namespace std;#define max(x,y) x>y?x:y#define maxn 1507#define ll long longll dp[maxn][maxn];ll n,dg,db,dr,st;void init(int tt){ ll t1,t2,ans=0; memset(d原创 2014-08-13 14:48:02 · 818 阅读 · 0 评论 -
hdu 4906 Our happy ending 状态压缩dp
#include#include#include#include#includeusing namespace std;#define maxn 1<<21#define mod 1000000007#define ll long longll dp[2][maxn];void add(ll&a,ll b){ a+=b; if(a >= mod) a-=mod原创 2014-08-04 21:04:13 · 928 阅读 · 0 评论 -
hdu 4899 Hero meet devil 2014多校联合训练赛 状态压缩dp 最长公共子序列
#include#include#include#includeusing namespace std;#define maxn 1<<15#define ll int#define mod 1000000007ll dp[2][maxn];int con[maxn][5];int ID[200];int value[20];char word[20];int queue原创 2014-08-04 16:02:49 · 1095 阅读 · 0 评论 -
hdu 4870 Rating
概率dp原创 2014-07-22 21:02:21 · 583 阅读 · 0 评论 -
hdu 5324 Boring Class 2015多校联合训练赛3 分治,最长不降子序列,最小字典序
Boring ClassTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 354 Accepted Submission(s): 75Problem DescriptionMr. Zstu and Mr.原创 2015-07-29 16:23:46 · 1331 阅读 · 0 评论 -
hdu 5330 Route Statistics 2015多校联合训练赛4 状态压缩
Route StatisticsTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 66 Accepted Submission(s): 22Problem DescriptionJRY is so r原创 2015-08-06 09:23:53 · 1465 阅读 · 0 评论 -
hdu 5291 Candy Distribution 2015 Multi-University Training Contest 1
Candy DistributionTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 37 Accepted Submission(s): 7Problem DescriptionWY has n kin原创 2015-07-22 09:33:59 · 1935 阅读 · 1 评论 -
hdu 5418 Victor and World 状态压缩dp,旅行商问题
Victor and WorldTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/131072 K (Java/Others)Total Submission(s): 385 Accepted Submission(s): 160Problem DescriptionAfter try原创 2015-08-23 13:09:21 · 1093 阅读 · 3 评论 -
hdu 5362 Just A String 2015多校联合训练赛#6 动态规划
Just A StringTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 221 Accepted Submission(s): 40Problem Descriptionsoda has a ra原创 2015-08-07 15:41:11 · 1410 阅读 · 3 评论 -
hdu 5411 CRB and Puzzle 2015 多校联合训练赛#10 快速矩阵幂
CRB and PuzzleTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 69 Accepted Submission(s): 35Problem DescriptionCRB is now play原创 2015-08-20 20:18:45 · 906 阅读 · 1 评论 -
hdu 5489 Removed Interval 动态规划,最长上升子序列
Removed IntervalTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 849 Accepted Submission(s): 310Problem DescriptionGiven a seq原创 2015-10-03 16:22:25 · 917 阅读 · 0 评论 -
hdu 5406 2015 多校联合训练赛#10 dp
CRB and AppleTime Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 358 Accepted Submission(s): 109Problem DescriptionIn Codeland t原创 2015-08-24 08:44:15 · 1010 阅读 · 1 评论 -
hdu 5410 CRB and His Birthday 2015多校联合训练赛#10 dp 动态规划
CRB and His BirthdayTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 132 Accepted Submission(s): 72Problem DescriptionToday is原创 2015-08-20 20:25:29 · 694 阅读 · 0 评论 -
hdu 5396 Expression 2015多校联合训练赛#9 动态规划 dp
ExpressionTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 372 Accepted Submission(s): 209Problem DescriptionTeacher Mai has n原创 2015-08-19 15:45:43 · 787 阅读 · 0 评论 -
hdu 5389 Zero Escape 2015多校联合训练赛#8 动态规划
Zero EscapeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 207 Accepted Submission(s): 91Problem DescriptionZero Escape, is原创 2015-08-13 19:53:28 · 1066 阅读 · 0 评论 -
hdu 5378 Leader in Tree Land 2015多校联合训练赛 树形dp
Leader in Tree LandTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 169 Accepted Submission(s): 62Problem DescriptionTree land原创 2015-08-12 16:14:19 · 1156 阅读 · 0 评论 -
hdu 5375 Gray code 2015多校联合训练赛#7
Gray codeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 369 Accepted Submission(s): 205Problem DescriptionThe reflected bina原创 2015-08-12 09:03:24 · 579 阅读 · 0 评论 -
HDU 5371 Hotaru's problem 2015多校联合训练赛7
Hotaru's problemTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 243 Accepted Submission(s): 61Problem DescriptionHotaru Ichij原创 2015-08-11 18:54:27 · 815 阅读 · 0 评论 -
Viterbi 算法
import java.util.*;/** * https://zh.wikipedia.org/zh-hans/%E7%BB%B4%E7%89%B9%E6%AF%94%E7%AE%97%E6%B3%95 * https://vimsky.com/article/863.html * @author gdretop * @date 2019/7/12 */public cla...原创 2019-07-12 17:19:59 · 267 阅读 · 0 评论