![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
动态规划
文章平均质量分 51
soul11201
这个作者很懒,什么都没留下…
展开
-
bit 1015 Edit Distance
Edit Distance时间限制: 1秒 内存限制: 64MProblem DescriptionGiven a string, an edit script is a set of instructions to turn itinto another string. There arethree kinds of operations in an edit scri原创 2013-02-15 21:53:07 · 495 阅读 · 0 评论 -
poj 1458 动态规划解最长公共子序列问题
参考blog:http://blog.csdn.net/yysdsyl/article/details/4226630【问题】 求两字符序列的最长公共字符子序列问题描述:字符序列的子序列是指从给定字符序列中随意地(不一定连续)去掉若干个字符(可能一个也不去掉)后所形成的字符序列。令给定的字符序列X=“x0,x1,…,xm-1”,序列Y=“y0,y1,…,yk-1”是原创 2013-06-28 22:45:46 · 848 阅读 · 0 评论 -
NYOJ_79_拦截导弹
http://acm.nyist.net/JudgeOnline/problem.php?pid=79先前写过是N^2复杂度,现在是个nlgn复杂度的。 #include#includeusing namespace std;int q(int *num,int B,int E,int elem){ if(B>=E) return E;原创 2013-06-25 22:07:45 · 949 阅读 · 0 评论 -
NYOJ_17_单调递增最长子序列
http://acm.nyist.net/JudgeOnline/problem.php?pid=17 裸的求最长递增子序列。不过要用二分查找+栈优化,不然用二重循环dp会tle#include #include int q(char *input,int begin,int end,char elem){ if(begin >= end) return原创 2013-06-25 20:09:55 · 921 阅读 · 0 评论 -
NYOJ 矩形嵌套
比如说矩形(a,b),要是能嵌入到矩形(c,d)中,abcd都为矩形的边长,不防假设a必须要a这样,只需要把所有的矩形按其最长边进行一次升序排列。然后,按其短边构成的序列,找出最长升序子序列就可。因为ainput_rec[i].a >input_rec[j].a && input_rec[i].b>input_rec[j].b总结起来算法就两步:1。将矩原创 2013-06-23 21:25:14 · 1269 阅读 · 0 评论 -
poj 2533
参考blog:http://blog.csdn.net/yysdsyl/article/details/4264650?reload http://www.slyar.com/blog/longest-ordered-subsequence.html http://www.slyar.com/blog/poj-2533-cpp.html时间复杂度N^2#incl原创 2013-06-08 21:48:23 · 682 阅读 · 0 评论 -
hdu 2602 bit 1013
01背包,具体不说,背包九讲写的真好。因为V_all这个数组一不小心在mian函数里面也定义了一个,结果导致本地测试时结果一直为零。#include #include int V_all[1100];void oneZero(int N,int V,int *V_each,int *value_each){ for(int i = 0;i<N;++i){ for(int j原创 2013-02-22 16:50:22 · 415 阅读 · 0 评论 -
hdu 1171 bit 1014
多重背包 :01+二进制优化。一开始 MultyPack函数for循环内因为没加 j = 0,结果一直Wa,最后多谢果神帮助。 #include #include #include int V_all[350000]; //dp的结果 int V; //背包的体积 //将一个体积为cost,价值为value的物品放入背包。 void ZeroOne(in原创 2013-02-22 19:22:34 · 449 阅读 · 0 评论 -
bit 1010 Maximum Sum
Maximum Sum时间限制: 2秒 内存限制: 64MProblem DescriptionGiven a set of n integers: A={a1, a2,..., an}, we define a function d(A) as below:d(A) = max(sum(a[i] +a[i+1] + … + a[j])) ( 1 Now your t原创 2013-02-15 23:34:17 · 529 阅读 · 0 评论 -
hdu 2955 Robberies
参考blog: http://blog.csdn.net/hellobabygogo3/article/details/7915083加上一点自己的感悟吧,开始这里楼判了等于0,因为他有可能没去偷钱,所以为零。因为去偷每一家银行的钱事件是独立的,所以有P(AB)= P(A)P(B);所以dp初始化为0。for(int i = sum;i>=0;--i)原创 2013-06-30 16:32:40 · 763 阅读 · 0 评论