lcs与上题基本一样
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAX 110
using namespace std;
char s1[MAX],s2[MAX];
int dp[MAX][MAX];
int main()
{
int i,j,l1,l2,t=1;
while(gets(s1)&&s1[0]!='#')
{
gets(s2);
l1=strlen(s1);
l2=strlen(s2);
memset(dp,0,MAX*MAX*4);
for(i=1;i<=l1;i++)
{
for(j=1;j<=l2;j++)
{
if(s1[i-1]==s2[j-1])
dp[i][j]=dp[i-1][j-1]+1;
else
dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
}
}
printf("Case #%d: you can visit at most %d cities.\n",t++,dp[l1][l2]);
}
return 0;
}