#include<iostream>
#include<string>
using namespace std;
![](http://www.cppblog.com/Images/OutliningIndicators/None.gif)
int dp[10005][10005];
![](http://www.cppblog.com/Images/OutliningIndicators/None.gif)
int main()
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif)
{
string str1;
string str2;
while(cin>>str1>>str2)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
// memset(dp,0,sizeof(dp));
int len1 = str1.length();
int len2 = str2.length();
int i,j;
for(i = 0;i <= len1;i++)
dp[i][0] = 0;
for(j = 0;j <= len2;j++)
dp[0][j] = 0;
for(i = 1;i <= len1;i++)
for(j = 1;j <= len2;j++)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if(str1[i-1] == str2[j-1])
dp[i][j] = dp[i-1][j -1] + 1;
else if(dp[i][j-1] > dp[i-1][j])
dp[i][j] = dp[i][j-1];
else
dp[i][j] = dp[i-1][j];
}
cout<<dp[len1][len2]<<endl;
}
return 0;
}