感觉这是一系列的动态规划的算法,正好也将动态规划的算法进行一个总结:
算法一:
带权重的最小路径的问题
Given a m x n grid
filled with non-negative numbers, find a path from top left to bottom right which minimizes the
sum of all numbers along i...
分类:
编程语言 时间:
2015-04-08 18:03:40
阅读次数:
167
题目You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent hous...
分类:
其他好文 时间:
2015-04-08 13:12:03
阅读次数:
133
欧几里得旅行商问题是一个NP问题,问题描述:平面上n个点,确定一条连接各点的最短闭合旅程。所以通常会简化为双调欧几里得问题来求一个近似解,借用下算法导论的图,如下所示a)是一个最优欧几里得b)为双调路线,从最左点开始严格向右至最右点通过动态规划求解,首先需要分析子问题:双调路径为 i -> 0,0 ...
分类:
其他好文 时间:
2015-04-08 10:48:41
阅读次数:
316
题目地址:https://leetcode.com/problems/wildcard-matching/动态规划解答:public class Solution { public boolean isMatch(String s, String p) { if(p.length...
分类:
其他好文 时间:
2015-04-08 10:35:44
阅读次数:
145
http://soj.sysu.edu.cn/show_problem.php?pid=1000&cid=1769sicilyTraveling Salesman Problem有编号1到N的N个城市,问从1号城市出发,遍历完所有的城市并最后停留在N号城市的最短路径长度。Input第一行整数 T :...
分类:
其他好文 时间:
2015-04-08 09:00:16
阅读次数:
506
转载:http://m.blog.csdn.net/blog/a511310132/13465985对于求次优解、第K优解类的问题,如果相应的最优解问题能写出状态转移方程、用动态规划解决,那么求次优解往往可以相同的复杂度解决,第K优解则比求最优解的复杂度上多一个系数K。其基本思想是将每个状态都表示成...
分类:
其他好文 时间:
2015-04-08 07:53:56
阅读次数:
147
单调递增最长子序列时间限制:3000ms | 内存限制:65535KB难度:4描述求一个字符串的最长递增子序列的长度如:dabdbf最长递增子序列就是abdf,长度为4输入第一行一个整数0 #include#includeusing namespace std;char s[10001];int d...
分类:
其他好文 时间:
2015-04-08 01:00:57
阅读次数:
119
蚂蚁的难题(二)时间限制:1000ms | 内存限制:65535KB难度:3描述下雨了,下雨了,蚂蚁搬家了。已知有n种食材需要搬走,这些食材从1到n依次排成了一个圈。小蚂蚁对每种食材都有一个喜爱程度值Vi,当然,如果Vi小于0的时候,表示蚂蚁讨厌这种食材。因为马上就要下雨了,所以蚂蚁只能搬一次,但是...
分类:
其他好文 时间:
2015-04-08 00:46:54
阅读次数:
167
题目链接:Scramble String
Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.
Below is one possible representation of s1 = "great":
...
分类:
其他好文 时间:
2015-04-07 23:33:46
阅读次数:
556