UVa 1588-kickdown__ Algorithm Contest Entry Classic (second edition)

Source: Internet
Author: User

Thought very well, at the beginning WA's time, see the problem is not part of the flip, want to flip all can AC, flip found also wrong, tried a few sets of data found a special data, processing or wrong, suddenly thought can not flip, so removed the flip, AC.

Special Data: 2222

211112



#include <stdio.h>
#include <string.h>
char h1[110],h2[110];
int main ()
{while
    (scanf ("%s%s", H1,H2)!=eof)
    {
        int i,j,t,m,n;
        int temp,conut1,conut2;
        i=j=t=0;
        M=strlen (H1);
        N=strlen (H2);
        while (J<m&&i<n)
        {
            if (h1[j]+h2[i]-96<=3)
            {
                i++,j++
            }
            else
                t++,i=0,j=t;
        }
        Conut1=m+n-i;
        i=j=t=0;
        while (j<n&&i<m)
        {
            if (h2[j]+h1[i]-96<=3)
            {
                i++,j++
            }
            else
                t++,i=0,j=t;
        }
        Conut2=m+n-i;
        printf ("%d\n", Conut1 < conut2? conut1:conut2);
    }
    return 0;
}


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.