Ultraviolet A 12545-bits equalizer (bit mutator)

Source: Internet
Author: User

Fortunately, the original idea of doing the question did not know when it would have formed this idea. It may have been a little more, so I naturally thought of using this method.

There is no reason. Is there any idea? If you have a idea, you can say something more. If you have a idea, then there is nothing to say about it... Let's learn more about the idea of the great gods. Maybe it's a way for cainiao to improve.

# Include <cstdio> # include <cstring> # include <string> # include <iostream> using namespace STD; string S1, S2; int cnt0, cnt1, cnt2; int main () {int t; scanf ("% d", & T); For (INT Kase = 1; Kase <= T; Kase ++) {CIN> S1> S2; cnt0 = cnt1 = cnt2 = 0; int cnt11 = 0, cnt21 = 0; For (INT I = 0; I <s2.size (); I ++) {If (S1 [I] = '? ') Cnt2 ++; If (S1 [I] = '1') cnt11 ++; If (s2 [I] = '1') cnt21 ++; if (s2 [I]! = S1 [I] & S1 [I]! = '? ') {If (s2 [I] = '0') cnt0 ++; If (s2 [I] = '1') cnt1 ++ ;}} if (cnt11> cnt21) {printf ("case % d:-1 \ n", Kase); Continue ;}int ans = 0; If (cnt0 = cnt1) {ans + = cnt0; ans + = cnt2;} If (cnt0> cnt1) {ans + = cnt1; ans + = (cnt0-cnt1); ans + = cnt2 ;} if (cnt0 <cnt1) {ans + = cnt0; ans + = (cnt1-cnt0); ans + = cnt2;} printf ("case % d: % d \ n", Kase, ans);} return 0 ;}

In fact, it can be merged, but I cannot write the merge process at once, and the depth of thinking cannot reach that level. If I think too deeply, I cannot understand it myself, an error occurs.

Think more, think deeply, and clarify your ideas.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.