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

why wa??

Posted by zctcheng at 2006-11-18 13:56:47 on Problem 1458
include<iostream.h>
#include<string.h>
const int MaxLen=1000;
int l[MaxLen][MaxLen];
int LCS(char *A,char *B)
{
	int m = strlen(A);
	int n = strlen(B);
	int i,j;
	for(i=0;i<=m;i++)
	{
		l[i][0]=0;
	}
	for(j=1;j<=n;j++)
	{
		l[0][j]=0;
	}
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(A[i-1]==B[j-1])
				l[i][j] = l[i-1][j-1]+1;
			else if(l[i][j-1]>l[i-1][j])
				l[i][j] = l[i][j-1];
			else
				l[i][j] = l[i-1][j];
		}
	}
	return l[m][n];
}
char a[MaxLen];
char b[MaxLen];
int main()
{	
	while(1)
	{
		cin>>a>>b;
		if(cin.eof()==1)break;
		cout<<LCS(a,b)<<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