UVA 12545(p253)----Bits Equalizer

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int t,l,zero,one,temp1,temp2,qnum;
string st1,st2;
int main()
{
    ios::sync_with_stdio(false);
    cin>>t;
    int cas=0;
    while(t--)
    {
        cin>>st1>>st2;
        cas++;zero=0;one=0;
        qnum=0;temp1=0;temp2=0;
        l=st1.length();
        for(int i=0;i<l;i++)
        {
            if(st1[i]=='?')
            {
                if(st2[i]=='0') zero++;
                if(st2[i]=='1') one++;
                qnum++;
            }
            if(st1[i]=='0'&&st2[i]=='1') temp1++;
            if(st1[i]=='1'&&st2[i]=='0') temp2++;
        }
        if(one+temp1<temp2) cout<<"Case "<<cas<<": "<<-1<<endl;
        else
          if(temp1>=temp2) cout<<"Case "<<cas<<": "<<temp1+qnum<<endl;
            else cout<<"Case "<<cas<<": "<<temp2+qnum<<endl;
    }
    return 0;
}

你可能感兴趣的:(UVA 12545(p253)----Bits Equalizer)