简单题
View Code
#include#include #include #include using namespace std; #define maxn 105 char st1[maxn], st2[maxn]; int getans(char *st1, char *st2) { int len1 = strlen(st1); int len2 = strlen(st2); for (int i = 0; i < len1; i++) { bool ok = true; for (int j = i; j < min(i + len2, len1); j++) if (st1[j] == '2' && st2[j - i] == '2') { ok = false; break; } if (ok) return max(len1, i + len2); } return len1 + len2; } int main() { //freopen("t.txt", "r", stdin); scanf("%s%s", st1, st2); int ans = getans(st1, st2); ans = min(ans, getans(st2, st1)); printf("%d\n", ans); return 0; }