Wine splitting problem and JOJ 1200 Jugs

Source: Internet
Author: User

 

Joj 1200 jugs
Question link:
Http://acm.jlu.edu.cn/joj/showproblem.php? PID = 1, 1200

The question is: There are two containers with the capacity
CA
And
CB

,
Ca <CB

At first, both containers were empty and the water supply was unlimited.
N
The unit of water is put in capacity
CB

In the container?

The data given by this question is ensured to have a solution, and anyone who sees this question will think of using search to solve this question. Search is also very simple, and the most easy to think of is the wide search. intuitively, this problem is very similar to that of the tower, and may also use algorithms like the tower. When searching, the status is the current two capacities of water
Wa

And
WB

, If
WB

Not equal
N
To perform the following six operations:
Fill
A, fill B, empty a, empty B, pour a B, pour B
. This question
AC
The code is exactly the breadth of search.

Now, as an interesting mathematical question, let's take a look at its nature. This is a famous Poisson liquor splitting problem. There is an article on the Internet that provides an in-depth analysis of such problems. This article is:

Http://blog.sina.com.cn/s/blog_41482c9f0100cts1.html

But those problems are slightly different from the situations of this question. I want to understand the following questions:

1.



Fill
And
Empty
The operation is to fill up or clear the container,
Pour
The operation is to pour the water of one container into another until the other is full or the container is empty. Therefore, it is clear that at any time, two containers are empty or one is full.

2.



This problem must be solved under what circumstances and under what circumstances.
N> cb

There must be no solution. Is there a value?
N0
Make
N <n0
Is there no solution?

3.



If you can generate
K
Can the unit of water be measured?
Mk

Unit of water, where
M
Is a positive integer and
Mk
<= Cb

.

4.



Intuitively, this question and two capacities
Ca, cb

Is the Euclidean Algorithm useful here.
(
In addition, the article above also introduces the method of the binary one-time Indefinite Equation. The result of the binary one-time indefinite equation is a multiple of the maximum common divisor of these two numbers.
)

The knowledge of mathematics is too low. I can only think of these problems and cannot prove them. Now let's record the problem here. Let's take a look at it later.

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.