******动态规划*******
文章平均质量分 74
猿的进化之路
这个作者很懒,什么都没留下…
展开
-
hdu1561 树形dp
超链接 汉语题,树形dp,dp[u][j],表示u点包括u点以下的点一共有j个点被使用了,那么u点与v点是怎么递推的呢,u是v的父节点,u要选择j个,那么从v里选择k个节点,从u里选j-k个节点,组成j个节点。#include <set>#include <map>#include <stack>#include <queue>#include <math.h>#include <vec原创 2017-09-02 12:10:52 · 267 阅读 · 0 评论 -
石子合并最快算法
#include #include #include #include #include #include using namespace std;const int N = 50005;const int INF = 0x7fffffff;typedef long long LL;int stone[N];int n,t;LL ans;void combine(in原创 2016-08-08 20:21:01 · 525 阅读 · 0 评论 -
一路二路最长单调递增子序列 hdu3998 + ACdream 1216
SequenceTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2120 Accepted Submission(s): 771Problem DescriptionThere is a sequenc原创 2016-06-13 11:31:46 · 319 阅读 · 0 评论 -
hdu5375 dp
C - Gray codeTime Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64uSubmit Status Practice HDU 5375Appoint description: System Crawler (Aug 27, 2016 6:33:50 PM)原创 2016-08-29 17:33:58 · 473 阅读 · 0 评论 -
hdu5326 树形dp
C - WorkTime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit Status Practice HDU 5326Appoint description: System Crawler (Aug 24, 2016 8:38:50 AM)D原创 2016-08-25 14:52:25 · 304 阅读 · 0 评论 -
51nod最长公共子序列
输入第1行:字符串A第2行:字符串B(A,B的长度 输出输出最长的子序列,如果有多个,随意输出1个。输入示例abcicbaabdkscab输出示例abca请选取你熟悉的语言,并在下面的代码框中完成你的程序,注意数据范围,最终结果会造成Int32溢出,这样会输原创 2016-07-02 18:27:27 · 447 阅读 · 0 评论 -
hdu4651
(OI)选手”——报考杭州电子科技大学!PartitionTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1099 Accepted Submission(s): 648Problem原创 2016-07-02 11:03:04 · 658 阅读 · 0 评论 -
hdu1069 Monkey and Banana
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=68966#problem/C、#include #include #include #include #include using namespace std;struct ac{ int x,y,z,high,dp;} d[205];bool cmp(ac原创 2015-12-30 16:23:42 · 336 阅读 · 0 评论 -
hdu5188限制01背包
zhx and contestTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 731 Accepted Submission(s): 271Problem DescriptionAs one of th原创 2016-05-19 11:48:27 · 412 阅读 · 0 评论 -
循环最大子段和
循环最大字段和等于 max (普通最大字段和, sum-最小子段和)因为总和是一定的,当最小子段在中间部分(不包含头尾)时,最大子段和等于总和-最小子段和;输入第1行:整数序列的长度N(2 <= N <= 50000)第2 - N+1行:N个整数 (-10^9 输出输出循环数组的最大子段和。原创 2016-05-07 21:38:45 · 269 阅读 · 0 评论 -
最大子段和的以为与二维求解
一维最大子段和很简单int ans=0,dp=0;for(int i=1;i<n;i++) if(dp>0) dp+=a[i]; else dp=a[i];输入第1行:M和N,中间用空格隔开(2 <= M,N <= 500)。第2 - N + 1行:矩阵中的元素,每行M个数,中间用空格隔开。(-10^9 输出原创 2016-05-07 21:15:04 · 444 阅读 · 0 评论 -
hdu4745区间dp
B - Two RabbitsTime Limit:5000MS Memory Limit:65535KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionLong long ago, there lived two rabbits Tom and Jerry in the fores原创 2016-05-06 21:12:47 · 309 阅读 · 0 评论 -
hdu4286
C - You Are the OneTime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit StatusDescription The TV shows such as You Are the One has been very popular. I原创 2016-05-07 11:39:21 · 639 阅读 · 0 评论 -
hdu1712分组背包
B - ACboy needs your helpTime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionACboy has N courses this term, and he plans to spend at m原创 2016-05-17 20:25:08 · 275 阅读 · 0 评论 -
hdu5389 dp
C - Zero EscapeTime Limit:1000MS Memory Limit:131072KB 64bit IO Format:%I64d & %I64uSubmit Status Practice HDU 5389Appoint description: System Crawler (Aug 31, 2016 9:42:06 AM原创 2016-08-31 17:26:37 · 419 阅读 · 0 评论 -
UVALive 4015 树形dp
A - CavesTime Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmit Status Practice UVALive 4015 uDebugAppoint description: System Crawler (Aug 31, 2016 11:09:27 P原创 2016-09-06 11:24:44 · 350 阅读 · 0 评论 -
hdu5416 树形dp 树上路径异或和
D - CRB and TreeTime Limit:4000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64uSubmit Status Practice HDU 5416Appoint description: System Crawler (Aug 31, 2016 7:27:46 PM原创 2016-09-02 17:00:55 · 1993 阅读 · 0 评论 -
hdu6156 数位dp
传送门 求K进制下回文数字个数,用一个数组记录每一位的数字,当跑到比中间位靠右时比较是否和对称位置相同即可,数组开全局,dfs之前进行赋值即可,是回文数字,权值是k否则是1,所以结果要加上1的部分。#include <stdio.h>#include <string.h>#include <algorithm>#include <iostream>using namespace std;原创 2017-08-21 20:07:04 · 402 阅读 · 0 评论 -
hdu6148 数位dp
传送门 题意:求区间内 数字是V型 的数字个数,这是套路题,dp[i][j][k],表示第i位前一位是j状态位K的数字个数,这基本都是套路,状态k就两种,1表示递增,0表示非递增,然后其他 的都是套路的东西,dfs(int pos,int pre,int sta,int limit),pos当前位,pre上一位的值,sta K的状态,limit 上一位是否是 上界,每次根据sta的状态来跑,sta原创 2017-08-21 20:02:32 · 424 阅读 · 0 评论 -
poj1185状压dp
传送门 汉语题,就不解释了。 m<=10,且炮的距离是2,那么仅仅考虑一行,0000000000—-1111111111,(1表示放,0表示不放)这些状态中最多有60个能放下炮的状态。称为可行状态S; 放置4个情况1种, 3个情况(4+3+2+1)+(3+2+1)+(2+1)+1=20, 2个情况为7+6+5+4+3+2+1=28, 放置1个为10中, 放置0个为1种,其和为60种。原创 2017-08-02 20:27:34 · 280 阅读 · 0 评论 -
poj3252 数位dp
Round NumbersTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 11955 Accepted: 4512DescriptionThe cows, as you know, have no fingers or thumbs and thus ar原创 2016-08-05 15:52:34 · 318 阅读 · 0 评论 -
hdu6035树形dp
“真的难”系列。 首先这题肯定是算贡献,也就是计算出每种颜色参与了多少条路径,但这样正面考虑并不容易,不妨从反面考虑,计算每种颜色没有参与多少路径,然后拿 (路径总数 * 颜色总数) - 没参与的贡献,就是答案了。 对于一种颜色x,怎么计算没参与的路径数目呢,很显然,对于每个不包含颜色x的连通块中任意两点路径都是x不参与的贡献,那么问题就转化为,对于任意一种颜色x,需要求出每个不包含x的连通转载 2017-08-02 10:41:22 · 278 阅读 · 0 评论 -
poj2288 状压dp
传送门 题意:有n个点,m条边,每个点有一个权值,求一条哈密顿回路,但是权值计算不同,包括三部分:1,经过的所有点的权值相加。2,经过的连续两个点的权值的乘积。3,能够构成三角型的连续三个点的乘积。这些全部加起来就是这条回路的总权值。输出最大权值和这个最大权值的路线有多少条。 状压dp,由于当前位置只和前两个点的位置有关,所以我们用dp[s][i][j],表示从i走到了j,目前倒数第二走到的是i原创 2017-08-08 10:16:47 · 283 阅读 · 0 评论 -
hdu4571
题目链接 hdu4571 problem GTravel in timeTime Limit: 8000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2787 Accepted Submission(s): 622Problem Description原创 2017-06-02 20:45:29 · 335 阅读 · 0 评论 -
hdu4568
题目链接hdu4568HunterTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2165 Accepted Submission(s): 679Problem Description One day, a hunter na原创 2017-06-02 21:10:45 · 414 阅读 · 0 评论 -
林大oj滑雪
滑雪Problem:ATime Limit:1000msMemory Limit:65536KDescription每到冬天,信息学院的张健老师总爱到二龙山去滑雪,喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来原创 2017-05-17 13:27:43 · 771 阅读 · 0 评论 -
弱校联萌第三场 I 数位dp 好题,可以用来入门
点击打开题目链接 题意就不说了,求 [l-r] momo数,代码里有详解#include #include #include #include using namespace std;typedef long long LL;LL dp[20][10][3],f[20];int a[20];LL dfs(int p,int x,int lis,int flag){原创 2016-10-07 19:12:09 · 318 阅读 · 0 评论 -
2016年弱校联萌 H
题目链接https://acm.bnu.edu.cn/v3/problem_show.php?pid=52305 problem descriptionIn ICPCCamp, there are n cities and (n−1) (bidirectional) roads between cities. The i-th road is between th原创 2016-10-03 11:00:49 · 445 阅读 · 0 评论 -
hdu4003
Find Metal MineralTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 3474 Accepted Submission(s): 1615Problem DescriptionHumans原创 2016-10-17 20:54:42 · 615 阅读 · 0 评论 -
hdu4714 树形dp
Tree2cycleTime Limit: 15000/8000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others)Total Submission(s): 2218 Accepted Submission(s): 526Problem DescriptionA tree with N原创 2016-09-19 21:22:27 · 370 阅读 · 0 评论 -
poj1276多重背包
D - Cash MachineTime Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64uSubmit Status Practice POJ 1276DescriptionA Bank plans to install a machine for cash原创 2016-05-17 20:14:32 · 273 阅读 · 0 评论 -
01背包第k大价值hdu2639
A - Bone Collector IITime Limit:2000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionThe title of this problem is familiar,isn't it?yeah,if you原创 2016-05-17 17:04:18 · 523 阅读 · 0 评论 -
树形dp-hdu1561
C - The more, The BetterTime Limit:2000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionACboy很喜欢玩一种战略游戏,在一个地图上,有N座城堡,每座城堡都有一定的宝物,在每次游戏中ACboy允许攻克M个原创 2016-04-07 21:34:28 · 450 阅读 · 0 评论 -
树形dp-CodeForces 581F
A - Contest PageTime Limit:3000MS Memory Limit:524288KB 64bit IO Format:%I64d & %I64uSubmit Status Practice CodeForces 581FDescriptionIt's election time in Berland. The fav原创 2016-04-07 21:13:48 · 427 阅读 · 0 评论 -
树形dp--hdu4123
D - Bob’s RaceTime Limit:2000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit Status Practice HDU 4123DescriptionBob wants to hold a race to encourage people to原创 2016-04-04 22:01:40 · 383 阅读 · 0 评论 -
树形dp--hdu4616
B - GameTime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit Status Practice HDU 4616Description Nowadays, there are more and more challenge game o原创 2016-04-04 12:29:27 · 281 阅读 · 0 评论 -
树形dp--hdu5379
C - Mahjong treeTime Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64uSubmit Status Practice HDU 5379DescriptionLittle sun is an artist. Today he is playing原创 2016-04-04 12:14:46 · 281 阅读 · 0 评论 -
poj3001
D - TravellingTime Limit:3000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit Status Practice HDU 3001DescriptionAfter coding so many days,Mr Acmer wants to ha原创 2016-03-27 16:25:52 · 391 阅读 · 0 评论 -
编辑距离问题
给定两个字符串S和T,对于T我们允许三种操作:(1) 在任意位置添加任意字符(2) 删除存在的任意字符(3) 修改任意字符 问最少操作多少次可以把字符串T变成S? 例如: S= “ABCF” T = “DBFG”那么我们可以(1) 把D改为A(2) 删掉G(3) 加入C所以答案是3。分析: 这个最少的操作原创 2016-03-27 20:53:55 · 480 阅读 · 0 评论 -
dp专题1,,hdu4568
),英雄互娱(杭州)HunterTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1671 Accepted Submission(s): 504Problem Description原创 2016-03-20 19:35:52 · 275 阅读 · 0 评论