Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 1458求解..编译不过

Posted by Magic_M at 2011-07-20 09:23:12 on Problem 1458
```#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
#define max(a,b)  ((a)>(b):(a)?(b))
char code[1005],code1[1005];
int dp[1005][1005];
int main()
{
while(scanf("%s%s",code,code1)==2)
{
int i,j;
memset(dp,0,sizeof(dp));
int n=strlen(code);
int m=strlen(code1);
for(i=0;i<n;i++)
for(j=0;j<m;j++)
{
if(code[i]==code1[j])
{
if(i>=1&&j>=1)
{
dp[i][j]=dp[i-1][j-1]+1;
dp[i][j]=max(dp[i][j],dp[i-1][j]);
dp[i][j]=max(dp[i][j],dp[i][j-1]);
}
else dp[i][j]=1;
}
else {
if(i>=1&&j>=1)dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
else if(i>=1)dp[i][j]=max(dp[i][j],dp[i-1][j]);
else if(j>=1)dp[i][j]=max(dp[i][j],dp[i][j-1]);
else dp[i][j]=0;
}
}
cout<<dp[n-1][m-1]<<endl;
}
return 0;
}```

Followed by: