中易网

帮我讲下题目要求的是什么?... (要求解什么)

答案:2  悬赏:70  
解决时间 2021-02-18 10:53
Common Subsequence
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 2 Accepted Submission(s) : 1
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description
A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = another sequence Z = is a subsequence of X if there exists a strictly increasing sequence of indices of X such that for all j = 1,2,...,k, xij = zj. For example, Z = is a subsequence of X = 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.
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.
Sample Input
abcfbc abfcab
programming contest
abcd mnp
Sample Output
4
2
0
最佳答案
样例输入两个字符串 str1 和 str2
输出 str1 和 str2 的最长公共子序列的长度
e.g:
str1="a b c f b c";
↑↑ ↑ ↑
↓↓ ↓ ↓
str2="a b f c a b";
str1 和 str2 的最长公共子序列是: 'a','b','c','b'
so输出的是 4
注意:子序列不是子串,子序列是这些字符不是连续的 但是有先后顺序;子串是连续的。
全部回答
序列的子序列是将所给序列略去几个元素或者一个不略。给出一个序列X = ,另一个序列 Z = 是X的子序列 如果存在一个序列X的指数的严格递增的子序列 即对于所有的j = 1,2,...,k, xij = zj。例如,Z = 是含指数序列<1, 2, 4, 6>的 X = 的子序列。现给出两个序列X和Y,要求找出X和Y最大长度公共子集。 输入数据来自文本文件。文件中的每个数据都由两个字符串组成来表明所给序列。各个序列由空格隔开。输入数据是正确的
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
电脑屏幕是LED背光好还是IPS雾面屏好?
老凤祥银楼莆田万达专营店地址有知道的么?有
如何和高利润产品谈合作
现在天猫下单不付款,直接投诉,容易被封号吗
灵占天下算命占卜软件八字算命准不准?我算出
英侯村怎么去啊,有知道地址的么
汽车的后视镜要怎么样才能防范后车的远光灯
联通宽带安装首月怎么收费?怎么算时间的!
西蒙电气地址在哪,我要去那里办事
7乘小括号三加x或者减十二等于五x加八十八
题破山寺后禅院所描绘的意境
请问湖南益阳有哪些做厨具与酒店用品的?要齐
拍花子是什么意思
2010年外地交的社保能不能转到北京来 我不是
奥巴马是什么专业
推荐资讯
从日本买了一个电饭煲,一会煮饭不会用!哪位
马记烩面怎么去啊,有知道地址的么
足球全场多长串关是怎么解释?
结婚的时候要让老公把自己的名字也写在房产证
哪里有免费的大学教学视频下载,尤其是计算机
关于C++和编译的问题
蟹逅小座怎么去啊,有知道地址的么
烟台市买第二套住宅,按照新契税政策,契税怎
社保连续两月没扣款了,是怎么回事?我要找什
棱锥的体积怎么算 求公式!
win10如何设置有线和无线同时上内网和外网?
关于对母亲的英语作文
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?