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 |
内存使用怎么样才能下去啊……我的程序都成这样了……#include <stdio.h> unsigned char DP[2][251]; char str1[251],str2[251]; int main() { unsigned char i,j,n,m; while (scanf("%s%s",str1,str2)!=EOF) { for( i = 0;i<2;++i) for(j = 0;j<252;++j) DP[i][j] = 0; for(m = 0;str1[m];++m); for(n = 0;str2[n];++n); for(i =1;i<=m;++i) { for(j =1;j<=n;++j) { if(str1[i-1] == str2[j-1]) DP[i%2][j] = DP[(i-1)%2][j-1]+1; else if(DP[(i-1)%2][j]>DP[i%2][j-1]) DP[i%2][j] = DP[(i-1)%2][j]; else DP[i%2][j] = DP[i%2][j-1]; } } printf("%d\n",DP[m%2][n]); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator