
算法-动态规划
文章平均质量分 60
醉语梦
“These are the night that never die”
展开
-
整数划分
若有n=m1+m2+…+mi;(其中mi为正整数,并且1 如果{m1,m2,…,mi}中的最大值不超过m,即max(m1,m2,…,mi) 根据n和m的关系,考虑以下几种情况: 当n=1或m=1时显然f(n,m)=1 当n=m时,根据划分中是否包含n,可以分为两种情况: 1). 划分中包含n的情况,只有一种情况即为{n};原创 2018-01-18 14:59:22 · 258 阅读 · 0 评论 -
最长上升子序列(LIS)与最长公共子序列(LCS)
1.LIS : 给定一个序列,求它的最长上升子序列(n 第一种 O(n^2): dp[i] 为以i为开头的最长上升子序列长度 code1: #include #include using namespace std; int n,ans; int a[2005],dp[2005]; int main(){ scanf("%d",&n); for(int i=1;i原创 2018-01-13 21:41:55 · 226 阅读 · 0 评论