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 |
Re:为什么wa呀?不用dp不行吗?一遍遍的搜怎么样In Reply To:Re:为什么wa呀?不用dp不行吗?一遍遍的搜怎么样 Posted by:08300240056 at 2009-11-19 00:23:51 #include<iostream> #include<string> using namespace std; int count; void search(char *str1,char *str2) { if(strlen(str1)==0||strlen(str2)==0) return; int i,j; for(i=0;i<strlen(str1);i++) for(j=0;j<strlen(str2);j++) if(str1[i]==str2[j]){ count++; search(str1+i+1,str2+j+1); return; } } int main() { char str1[500],str2[500]; int max,i; while(scanf("%s%s",str1,str2)!=EOF){ max=0; for(i=0;i<strlen(str1);i++){ count=0; search(str1+i,str2); max=count>max?count:max; } printf("%d\n",max); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator