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

ft~~~怎么用scanf?我一用就tle,还有内存怎么开小些?

Posted by sunmoonstar_love at 2005-07-16 02:10:32 on Problem 1458
#include <cstring>
#include <iostream>
using namespace std;
#define max 350
char a[max],b[max];
int i,j,la,lb,f[max][max];
int main()
{
    for(i=0; i<max; i++)
        f[i][0] = f[0][i] = 0;
    while(cin>>a+1>>b+1)
    {
        la = strlen(a+1);
        lb = strlen(b+1);
        for(i=1; i<=la; i++)
            for(j=1; j<=lb; j++)
                if(a[i]==b[j])
                    f[i][j] = f[i-1][j-1]+1;
                else
                    f[i][j] = f[i-1][j]>f[i][j-1]?f[i-1][j]:f[i][j-1];  
        cout<<f[la][lb]<<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