Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

这个和1080差不多

Posted by TSERROF at 2012-11-12 22:10:32 on Problem 1458
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int dp[100][100];
int main()
{
	string s1,s2;
	while(cin>>s1>>s2)
	{
		memset(dp,0,sizeof(dp));
		for(int i=0;i<s1.size();++i)
			for(int j=0;j<s2.size();++j)
			{
				if(s1[i]==s2[j])dp[i+1][j+1]=dp[i][j]+1;
				else dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
			}
		cout<<dp[s1.size()][s2.size()]<<endl;
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator