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

晕,这代码咋过不到哦??

Posted by dynamic_study at 2009-07-18 20:01:05 on Problem 1458 and last updated at 2009-07-18 20:16:58
#include<iostream>
using namespace std;
#define MAX 1001
int main()
{
	int len1,len2,i,j;
	char s1[MAX],s2[MAX];
	int dp[MAX][MAX];
	while(cin>>s1+1>>s2+1)
	{
	len1=strlen(s1);
	len2=strlen(s2);
//	cout<<len1<<endl<<len2<<endl;
	for(i=0;i<len1;i++)
	{
		
		dp[i][0]=0;
	}
	for(j=0;j<len1;j++)
	{
		dp[0][j]=0;
	}
	for(i=1;i<len2;i++)
	{
		for(j=1;j<len2;j++)
		{
			if(s1[i]==s2[j])
				dp[i][j]=dp[i-1][j-1]+1;
			else 
			{
				dp[i][j]=dp[i-1][j]>dp[i][j-1]?dp[i-1][j]:dp[i][j-1];
			}
		}
	}
	cout<<dp[len1-1][len2-1]<<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