专题三acm1002
来源:互联网 发布:淘宝商家客服服务电话 编辑:程序博客网 时间:2024/06/06 06:55
Problem Description
A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = <x1, x2, ..., xm> another sequence Z = <z1, z2, ..., zk> is a subsequence of X if there exists a strictly increasing sequence <i1, i2, ..., ik> of indices of X such that for all j = 1,2,...,k, xij = zj. For example, Z = <a, b, f, c> is a subsequence of X = <a, b, c, f, b, c> with index sequence <1, 2, 4, 6>. Given two sequences X and Y the problem is to find the length of the maximum-length common subsequence of X and Y. <br>The program input is from a text file. Each data set in the file contains two strings representing the given sequences. The sequences are separated by any number of white spaces. The input data are correct. For each set of data the program prints on the standard output the length of the maximum-length common subsequence from the beginning of a separate line. <br>
Sample Input
abcfbc abfcabprogramming contest abcd mnp
Sample Output
420(1)大意:给出两个序列X、Y,让我们编写一个程序,求出这两个序列最长的公共上升子序列。(2)思路:与课上讲的例题,十分相似,所以不再多说,用动态规划的思想,排除重复计算,得到最后的结果。(3)感想:消化课上讲的,就很好,这些问题就能很好的解决。(4)#include <iostream>#include <cstdio>using namespace std;int main(){ int i,ca=1,t,s,e,n,x,now,before,max; scanf("%d",&t); while(t--) { scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%d",&now); if(i==1) { max=before=now; x=s=e=1; } else { if(now>now+before) { before=now; x=i; } else before+=now; } if(before>max) {max=before,s=x,e=i;} } printf("Case %d:\n%d %d %d\n",ca++,max,s,e); if(t) { printf("\n"); } } return 0;}
0 0
- 专题三acm1002
- acm1002
- acm1002
- ACM1002
- PKU-ACM1002
- 杭电ACM1002
- 杭电ACM1002题
- 北大acm1002解题报告
- acm1002 大数相加
- 杭电ACM1002题
- 杭电ACM1002
- 杭电acm1002
- acm1002大数加法
- 3G专题三
- LDAP专题(三)
- IPV6专题(三)
- 专题三1006
- 专题三1001
- 关于angularJS绑定数据时自动转义html标签
- 计算机网络面试题总结
- Android listview的setemptyview
- MyBatis简介与配置MyBatis+Spring+MySql
- Android重点知识大集结
- 专题三acm1002
- @property属性详解
- 漫谈 iOS Crash 收集框架
- C# webservices 之自定义编写发布【2】
- Sublime Text使用技巧
- linux 目录、复制、创建、剪切、重命名、删除
- mysql key duplicate
- Java反射的一点个人理解
- Nginx反向代理和负载均衡的了解