| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
ft~~~怎么用scanf?我一用就tle,还有内存怎么开小些?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator