This problem thinking is not difficult to think, in the process of doing the main problems encountered are:
Because there is no careful consideration of the boundary situation, there is no comprehensive analysis, resulting in a large amount of time wasted due to the lack of access to the correct results.
In the future to do such topics, we must first carry out a more comprehensive analysis + simulation, and then write code, to avoid wasting time.
1#include <cstdio>2#include <cstring>3#include <algorithm>4 using namespacestd;5 #defineMAXN 10006 intMain () {7 intLen1,len2;8 CharS1[MAXN],S2[MAXN];9 while(SCANF ("%s%s", s1,s2)! =EOF) {Tenlen1=strlen (S1); OneLen2=strlen (S2); A for(inti=len1;i<len1+len2;i++) s1[i]='0'; - for(inti=len2;i<len1+len2;i++) s2[i]='0'; - intOK; the intminv=MAXN; - for(intI=0; i<=len2;i++){ -ok=1; - for(intj=0; J<min (len1,len2-i); J + +){ + if(s2[i+j]+s1[j]-2*'0'>3){ -ok=0; + Break; A } at } - if(Ok&&max (len2,len1+i) <MINV) Minv=max (len2,len1+i); - } - for(intI=0; i<=len1;i++){ -ok=1; - for(intj=0; J<min (len2,len1-i); J + +){ in if(s1[i+j]+s2[j]-2*'0'>3){ -ok=0; to Break; + } - } the if(Ok&&max (len1,len2+i) <MINV) Minv=max (len1,len2+i); * } $printf"%d\n", MINV);Panax Notoginseng } - return 0; the}
Uva 1588 Kickdown