摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1160dp问题:状态转移——>:a[i]=a[j]+1;b[i]=j; //记录找到最下降序列的路径, 即下标标号思路:先按照重量递增排序,如果w相等,则按照速度v的递减顺序排序,最后找出以速度为关键字的递减最大子序列即可。代码如下:View Code #include<iostream>#include<algorithm>using namespace std;int b[1001];int a[1001];int c[1001];struct node{ int w; in 阅读全文
posted @ 2011-05-03 16:45 聊聊IT那些事 阅读(474) 评论(1) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1159直接模板!View Code #include"iostream"using namespace std;char a[1001],b[1001];int c[1001][1001];int Max(int a, int b){ return a>b?a:b;}void LCS(char *aa , char *bb, int x, int y){ int i,j; for(i=0;i<=x;i++) c[i][0]=0; for(j=0;j<=y;j++) c[0 阅读全文
posted @ 2011-05-03 09:51 聊聊IT那些事 阅读(352) 评论(1) 推荐(0)