摘要:
最长上升/不下降子序列:(LIS)有两种方法:1.动态规划,O(n^2)容易得出O(n^2)的DP递推公式:D[i]=max{D[j]}+1;(1<=j<i且E[j]<E[i])D[i]为以元素i结尾的最长子序列个数。这样经过两重循环一次遍历可以得到最长上升子序列。代码:View Code 1 #include <iostream> 2 #include <stdio.h> 3 #include <cstring> 4 using namespace std; 5 const int maxnum=100; 6 int a[maxnum], 阅读全文
posted @ 2012-08-27 11:01
pushing my way
阅读(340)
评论(0)
推荐(0)

浙公网安备 33010602011771号