Nyoj 213 cups of water

Source: Internet
Author: User
Three water cups time limit:ms | Memory limit:65535 KB Difficulty:4
Describe
give three cups, different sizes, and only the largest cup of water is filled, the remaining two are empty cups. Three cups of water are poured between each other, and the cups are not identified and can only be calculated according to the volume of the cups given. You are now asked to write a program that outputs the minimum number of times that the initial state reaches the target State.
Input
The first line an integer n (0<n<50) indicates that the N group of test data next to each set of test data has two lines, the first row gives three integers V1 V2 V3 (v1>v2>v3 v1<100 v3>0) represents the volume of three cups. The second line gives three integers E1 E2 E3 (volume less than equal to the corresponding Cup volume) represents the final state we need
Output
Each row outputs the minimum number of water pours for the corresponding test data. If the target status output is not reached-1
Sample input
26 3 14 1 19 3 27 1 1
Sample output
3-1

Nyoj 213 cups of water

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.