1 #include<iostream> 2 3 using namespace std; 4 5 const int maxn =100+10; 6 7 char s[maxn],t[maxn]; 8 9 int main(){ 10 //freopen("10.in", "r", stdin); 11 //freopen("10.out", "w", stdout); 12 int n; 13 cin >> n; 14 for(int i = 1; i <= n; i ++){ 15 cin >> s >> t; 16 cout << "Case " << i << ": "; 17 int s1 = 0, t1 = 0, q1 = 0, num = 0; 18 int len = strlen(s); 19 for(int j = 0; j < len; j ++){ 20 if(t[j] == '0') t1 ++; 21 if(s[j] == '0') s1 ++; 22 if(s[j] == '?'){ 23 q1 ++; 24 num ++; 25 } 26 if(s[j] == '?' && t[j] == '0'){ 27 s[j] = '0'; 28 s1 ++; 29 q1 --; 30 } 31 } 32 if(s1 + q1 < t1){ 33 cout << "-1" << endl; 34 continue; 35 } 36 int sum = t1 - s1; 37 int s0 = 0, s2 = 0; 38 for(int k = 0; k < len; k ++){ 39 if(s[k] == '0' && t[k] == '1') s0++; 40 } 41 if(sum > 0){ 42 s0 += sum; 43 } 44 num += s0; 45 cout << num << endl; 46 } 47 return 0; 48 }