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 wocha at 2012-07-18 11:09:21 on Problem 1458
#include<stdio.h>
#include<string.h>
#include<iostream>
#define ma(a,b) a>b?a:b;
using namespace std;
int dp[513][522];
int main()
{
    int a,n,m,i,j;
    char s1[2222],s2[2222];
    while(~scanf("%s %s",s1,s2))
    {
        if(s1[0]=='0') break;
        int l1=strlen(s1);
        int l2=strlen(s2);
        memset(dp,0,sizeof(dp));
        for(i=0;i<l1;i++)
         for(j=0;j<l2;j++)
         {
                if(s1[i]==s2[j])
                {
                    dp[i+1][j+1]=dp[i][j]+1;
                }else{
                
                   dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
                }
                
        }
        printf("%d\n",dp[l1][l2]);
    }
}

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