Problem Description:
Box length x, width y, high Z. X, Y, and z are all positive integers. The box is made up of 1, 1, and 1 square bodies. So how many cubes does the cuboid body diagonal pass through?
This question considers the imagination of three-dimensional space. In recent studies, we have tried to consider two-dimensional cases, in the case of two-dimensional solution, in the extension to three-dimensional. The following is a description of the problem in the two-dimensional case
Rectangle long x, width y. Both X and y are positive integers. The rectangle consists of a square with a length of 1 and a width of 1. So how many squares does the diagonal of a rectangle cross?
Illustrated by an example. Rectangle length 6, Width 4. The rectangle consists of a square with a length of 1 and a width of 1. So how many squares does the diagonal of a rectangle cross?
This is still relatively simple, directly in the diagram, as shown in:
As shown, the diagonal crosses a total of 8 squares (the gray part). However, it is not possible to draw a picture of every problem, such as a length of 777, a width of 581 of the rectangular solution is difficult to draw a representation (the number is too large, not easy to accurately represent).
Take a closer look at the 8 squares that actually divide the diagonal into 8 segments. The end point of a line segment is the intersection of diagonal and horizontal (or vertical) lines.
As a result, the problem seems to translate into
How many squares are required to be crossed, in effect the number of segments to be asked
How many segments are required, in effect the number of intersections between the diagonal and horizontal and vertical lines
Put in the plane Cartesian coordinate system, the lower left corner coordinates (0,0), the upper right corner coordinates (6,4)
The line equation for the diagonal is
It's not the same as the linear equation we generally imagined. It doesn't matter, first of all, this is the correct linear equation, followed by the three-dimensional linear equation in the back of the expression of the unified form.
We marked the intersection of the diagonal and horizontal (or vertical line) on the graph (for the sake of later description, I use different colors to mark the points)
The beginning of the lower left corner is marked with a gray mark, and the red dots indicate the intersection of the diagonal and vertical lines (the horizontal axis of the intersection is an integer), and the green dots indicate the intersection of the diagonal and horizontal lines (the ordinate of the intersection is an integer)
The starting point does not count, and the number of squares crossed and the number of segments and the number of points are the same (all 8).
The coordinates of the red dots (the horizontal axis are integers) are:
The number of long values is consistent with the rectangle (yes 6)
The coordinates of the green point (the ordinate is an integer) are:
The number is consistent with the width of the rectangle (is 4)
As you can see, the red and green dots have 2 points that are coincident (with half-red and half-green dots on the graph), so these points together are as follows (sorted by the distance from the starting point)
The solution of the problem can be described as follows:
1, to find out the horizontal axis is an integer number of points, is the length of the rectangle value. This is 6.
2, to find out the ordinate is an integer number of points, is the value of the box width. This is 4.
3. Find the number of points coincident in step 1 and step 2, that is, the number of points where the horizontal ordinate is an integer. This is 2.
4. Answer to the question: answer to step 1 + answer to step 2-answer to step 3. This is 6+4-2=8.
Steps 1, 2, 3, 4, the key is step 3, how to find out steps 1 and step 2, the number of coincident points, that is, the horizontal ordinate is an integer number of points.
Greatest common divisor: positive integers A and B, if a can be divisible by B, then A is a multiple of B, and B is an approximate number of a. Positive integers A and b the largest number of the greatest common divisor, known as A and B, as GCD (A, A, a)
In the subject, (4,6) = 2, exactly is the counting of step 3, is coincidence? No, we'll prove it next.
Proof: Long X, width Y of the rectangle, diagonal through the double integer point (horizontal ordinate is an integer) number is gcd (x, y) (note: not the beginning)
X1=X/GCD (x, y), y1=y/gcd (x, y). Then both X1 and Y1 are integers, and x1 and Y1 coprime (except for 1, no convention number).
The line equation where the diagonal is
When x takes an integer (1≤x≤x), to make y also an integer, x must take a multiple of X1 (so that the denominator is completely out)
and between 1 and X, X1 multiples of gcd (x, y)
Proof complete.
In summary: Oblong length x, width y. Both X and y are positive integers. The rectangle consists of a square with a length of 1 and a width of 1. So how many squares does the diagonal of a rectangle cross?
The solution is: ans=x+y-gcd (x, y), which can be expressed
For example:
Length 6, Width 4 of the rectangular diagonal through 6+4-GCD (6,4) =6+4-2=8 a square
Length 5, Width 3 of the rectangular diagonal through 5+3-GCD (5,3) =5+3-1=7 a square
Length 12, Width 8 of the rectangular diagonal through 12+8-GCD (12,8) =12+8-4=16 a square
Extended to three-dimensional. Box length x, width y, high Z. X, Y, and z are all positive integers. The box is made up of 1, 1, and 1 square bodies. So how many cubes does the cuboid body diagonal pass through?
The linear equation of the body diagonal of a cube with long x, wide y, and High Z is
Although this equation is a bit strange, but the study of space analytic geometry understand the correctness of this equation
The process of solving is similar to the two-dimensional one, and also the point of finding coordinates as integers. Can be expressed by:
The solution is: ans=x+y+z-gcd (x, y)-gcd (x,z)-gcd (y,z) +gcd (x, Y, z)
For example:
Length 5, Width 3, height 4 cuboid body diagonal through 5+3+4-GCD (5,3)-gcd (5,4)-gcd (3,4) +gcd (5,3,4) =5+3+4-1-1-1+1=10 Cube
Length 8, Width 6, height 3 cuboid body diagonal through 8+6+3-GCD (8,6)-gcd (8,3)-gcd (6,3) +gcd (8,6,3) =8+6+3-2-1-3+1=12 Cube
Length 12, Width 8, height 6 cuboid body diagonal through 12+8+6-GCD (12,8)-gcd (12,6)-gcd (8,6) +gcd (12,8,6) =12+8+6-4-6-2+2=16 Cube
is long 5, width 3, high 4 of the box body diagonal through the cube, a total of 10 cubes, you see it?
How many cubes does the body diagonal of the "turn" cube pass through?