Time Limit: 1000 ms Memory Limit: 65536 KiB
Problem Description
给定两个序列 X={x1,x2,…,xm} 和 Y={y1,y2,…,yn},找出X和Y的最长公共子序列。
Input
输入数据有多组,每组有两行 ,每行为一个长度不超过500的字符串(输入全是大写英文字母(A,Z)),表示序列X和Y。
Output
每组输出一行,表示所求得的最长公共子序列的长度,若不存在公共子序列,则输出0。
Sample Input
ABCBDAB BDCABA
Sample Output
4
Hint
Source
#include <bits/stdc++.h>
using namespace std;
int main()
{
char s1[510], s2[510];
while (cin >> s1 >> s2)
{
int m = strlen(s1);
int n &#