码迷,mamicode.com
首页 >  
搜索关键字:aeai dp    ( 24629个结果
Leetcode: Climbing Stairs
用了DP的方法,还有hashtable 1 import java.util.*; 2 3 public class Solution { 4 public int climbStairs(int n) { 5 Hashtable table = new Hashtable...
分类:其他好文   时间:2014-05-23 08:31:02    阅读次数:234
poj 1141 Brackets Sequence(区间DP)
题目:http://poj.org/problem?id=1141转载:http://blog.csdn.net/lijiecsu/article/details/7589877定义合法的括号序列如下:1 空序列是一个合法的序列2 如果S是合法的序列,则(S)和[S]也是合法的序列3 如果A和B是合...
分类:其他好文   时间:2014-05-22 02:52:11    阅读次数:256
23.跳台阶问题
DP and Fib.
分类:其他好文   时间:2014-05-22 00:31:52    阅读次数:254
比较字符串总结:如果计算两个字符串的相似度或者距离
有关字符串相关比较问题,一般处理方法都选择动态规划处理方法。或者是单个循环,或者是多个循环;dp遇到这种两个串的问题,很容易想到DP。但是这道题的递推关系不明显。可以先尝试做一个二维的表int[][] dp,用来记录匹配子序列的个数(以S="rabbbit",T="rabbit"为例): r a b...
分类:其他好文   时间:2014-05-21 23:01:16    阅读次数:229
poj1160 Post Office 四边形不等式
在一条直线上有n个村庄,选出m个村庄,在其中每个村庄建立一个邮局,要求每个村庄到最近邮局的距离和最小。 f[i][j]:在前i个村庄中建立j个邮局的最小耗费 dis[i][j]:在第i个村庄到第j个村庄中建立1个邮局的最小耗费 那么就有转移方程:f[i][j] = min(f[i][j],f[k][j-1]+dis[k+1][i]) DP的边界状态即为f[i][1] = dis[1][i...
分类:其他好文   时间:2014-05-21 16:30:14    阅读次数:236
POJ 2192 Zipper
大体题意: 先输入试验次数num,再输入三个字符串A,B,C,判断C可否由A,B按照某种次序组成。如下图。 #include #include using namespace std; #define MAX_SIZE 205 char A[MAX_SIZE]; char B[MAX_SIZE]; char C[2 * MAX_SIZE]; bool...
分类:其他好文   时间:2014-05-21 16:05:09    阅读次数:209
hdu 1171 Big Event in HDU 多重背包
Big Event in HDU Problem Description Nowadays, we all know that Computer College is the biggest department in HDU. But, maybe you don't know that Computer College had ever been split into Comp...
分类:其他好文   时间:2014-05-21 10:51:55    阅读次数:300
hdu 1114 Piggy-Bank -- 完全背包
Piggy-Bank Problem Description Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound M...
分类:其他好文   时间:2014-05-21 10:17:35    阅读次数:289
HDU FATE (完全背包+有限取次)(二重费用背包)
FATE Problem Description 最近xhd正在玩一款叫做FATE的游戏,为了得到极品装备,xhd在不停的杀怪做任务。久而久之xhd开始对杀怪产...
分类:其他好文   时间:2014-05-21 10:16:18    阅读次数:194
多重背包模板
/** * 多重背包: * 有N种物品和一个容量为V的背包。第i种物品最多有Mi件可用, * 每件耗费的空间是Ci,价值是Wi。 * 求解将哪些物品装入背包可使这些物品的耗费的空间总和不超过背包容量,且价值总和最大。 */ #include #include int max(int a, int b){ if (a > b)return...
分类:其他好文   时间:2014-05-21 10:00:56    阅读次数:206
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!