Uva 1588-kickdown

Source: Internet
Author: User

Test instructions

Two bars with a length of n1,n2 (n1,n2<=100) and a height of 1 or 2 per column are given. They need to be placed in a container with a height of 3.

Ask for the shortest container length that can hold them.

Fix one, and the other moves on it, looking for the minimum length.

Since it is possible to choose which fixed, the minimum value is calculated two times.

For example:

2112112112
2212112

The above fixed, then 10, the following fixed, the minimum required 12.

1#include <cstdio>2#include <cstring>3#include <iostream>4#include <algorithm>5#include <cstdlib>6#include <cmath>7#include <cctype>8#include <vector>9#include <queue>Ten#include <map> One#include <Set> A #defineEPS 10e-6 -  - using namespacestd; the  -typedefLong Longll; -  - Chara[ the],b[ the]; +  - intMain () + { A      while(~SCANF ("%s%s", b)) at     { -         intLen1 = strlen (a), Len2 =strlen (b); -         intI=0, j=0, ans; -          while(I<len1 && j<len2) -         { -             if(a[i]-'0'+b[j]-'0'<=3) in             { -i++; toJ + +; +             } -             Else the             { *i = i-j+1; $j =0;Panax Notoginseng             } -         } theAns = len1+len2-J; +I=0, j=0; A          while(I<len1 && j<len2) the         { +             if(a[i]-'0'+b[j]-'0'<=3) -             { $i++; $J + +; -             } -             Else the             { -j = j-i+1;Wuyii =0; the             } -         } Wuprintf"%d\n", Min (ans,len2+len1-i)); -     } About     return 0; $}
View Code

Uva 1588-kickdown

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.