Dynamic Programming
问题一:Fibonacci 数列求解问题。
一般的会采用递归实现。
/****************************************************
code file : Fibonacci.c
code date : 2014.11.25
e-mail : jasonleaster@gmail.com
code...
分类:
其他好文 时间:
2015-02-04 14:46:41
阅读次数:
259
题目:《编程之美》P241
提示:利用动态规划的思想,保存每次循环所计算出来的数据,可以避免重复计算
class treenode
{
public:
int data;
shared_ptr left,right;
treenode(int d,const shared_ptr &l,const shared_ptr &r):data(d),left(l),right(r){}...
分类:
其他好文 时间:
2015-02-04 14:42:16
阅读次数:
112
最长递增子序列——解题报告
题目描述:给定一个数组,长度为n,求出其中最长递增子序列。
分析:这题可以用动态规划求解,遍历i = 1 : n,当第i个数比前面j数大,而且前面的子序列长度加1之后,比现在的第i个子序列长的话,那么就变换。额,晦涩难懂额。。看代码可以好一些。
代码如下:
#include
using namespace std;
...
分类:
其他好文 时间:
2015-02-04 13:06:17
阅读次数:
144
最近在项目中碰到了这样的一个问题,要比较JS和CSS是否做了修改,先是想着借助第三方工具发现没找到,后面转念一想,这个问题不就是对两个文件的第一行求最大的公共子串嘛,既然是要求公共子串的最大长度,由此想到了动态规划算法。代码是从网上C++改写过来的,感谢那位C++的兄弟,代码如下:package d...
分类:
编程语言 时间:
2015-02-04 10:58:32
阅读次数:
197
Follow up for "Unique Paths":
Now consider if some obstacles are added to the grids. How many unique paths would there be?
An obstacle and empty space is marked as 1 and 0 respectively in th...
分类:
编程语言 时间:
2015-02-04 09:28:40
阅读次数:
172
八大常见建模问题
1. 线性规划问题:
简称LP问题,使用单纯刑法进行求解。
如:如何利用现有资源来安排生产,以取得最大经济效益的问题
2. 整数规划
与线性规划类似,分支定界法求解。
3. 非线性规划
如投资类型的0-1规划问题;
4. 动态规划
动态规划(dynamicprogramming)是运筹学的一个分支,是求解多阶段决策...
分类:
其他好文 时间:
2015-02-03 17:25:11
阅读次数:
206
#1037 : 数字三角形
时间限制:10000ms
单点时限:1000ms
内存限制:256MB
问题描述
小Hi和小Ho在经历了螃蟹先生的任务之后被奖励了一次出国旅游的机会,于是他们来到了大洋彼岸的美国。美国人民的生活非常有意思,经常会有形形色色、奇奇怪怪的活动举办,这不,小Hi和小Ho刚刚下飞机,就赶上了当地的迷宫节活动。迷宫节里展览出来的迷...
分类:
其他好文 时间:
2015-02-03 15:11:30
阅读次数:
232
【题目】
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.
For example, given the following triangle
[
[2],
[...
分类:
其他好文 时间:
2015-02-03 11:07:52
阅读次数:
148
You are climbing a stair case. It takes n steps to reachto the top.
Each time you can either climb 1 or 2 steps. In how many distinct ways canyou climb to the top?
HideTags
Dynamic Programming
...
分类:
其他好文 时间:
2015-02-02 23:15:59
阅读次数:
283