The so-called vertical and horizontal graph is from 1 to n 2, and these n 2 natural numbers are arranged into squares with n rows and n columns according to the law of one benefit. It has a wonderful property. Appropriate numbers are arranged on tables of various geometric shapes. If you use simple logic to calculate these numbers, no matter which route you take, the final sum or product is exactly the same. Regarding the origin of the Rubik's Cube, China has River Map and Luo Shu. According to legend, in ancient times, Fu won the world, governed the country well, and replaced flowers. So a dragon horse jumped out of the Yellow River with a picture on its back and gave it to him as a gift. This is the "river map". The earliest deduction of gossip through "River Map" was the Rubik's Cube-Fu. Later, when Dayu was harnessing the water, a turtle surfaced. There are pictures and words on the back. There are 45 black and white circles in Luo Shu's painting. Put these small circles and numbers together and you get nine. These nine numbers can form a vertical and horizontal diagram. People call the magic square of nine numbers, three rows and three columns the third-order magic square. There are also four or five orders. ...
Later, after research, the formula for calculating the sum of all numbers in each row, column and diagonal of any order magic square is:
nn = 1/2n(n ^ 2+ 1)
Where n is the order of the magic square and the number to be solved is Nn.
The Rubik's Cube was recorded for the first time in China's "Da Dai Li" in the Spring and Autumn Period of 500 BC, which shows that our people knew the arrangement law of Rubik's Cube as early as 2,500 years ago. Abroad, it was not until 130 that the Greek Saiweng first mentioned the Rubik's Cube.
Our country not only has the right to invent the Rubik's Cube, but also is a country that conducts in-depth research on it. Yang Hui, a mathematician in the 3rd century A.D.10, compiled a magic square of order 3- 10, which was recorded in his book "Algorithm for Continuing Ancient Stories" written in 275. In Europe, it was not until 574 that famous German painters lost their efforts to draw a complete fourth-order Rubik's Cube.
The nature of the N- mesomagic square: the sum of the numbers in each row, column and diagonal is equal, and the tangent is N*(N*N+ 1)/2.
Let P[N*N] represent N*N squares.
1. For even N(N%4==0)
(1) Draw N*N squares first.
(2) Fill in 1, 2, ..., N*N from left to right and from top to bottom in the box.
(3) Divide the square of N*N into N*N/ 16 small squares of 4*4.
(4) Draw the diagonal of each 4*4 small square.
(5) The number on each diagonal is unchanged, and the number on the off-diagonal is interchanged with its symmetric number.
That is, a and N*N-A+ 1 and vice versa.
All right, it worked!
2.N%4==2
(1) Leave the first and last 2N-2 numbers of N*N numbers, and fill in the rest according to the method of 1.
Within (N-2)*(N-2) squares.
(2) Assembling the outer box
Come up with a complement method from 0 to 3 today:
Fill in some special figures first.
P[0]=3
P[N- 1]=N
P[ 1]= 1
P[N]=2
P[2]=N*N-3
P[3]=5
P[2N]=N+2
P[3N]=N+3
P[4]=N*N-5
Fill in the following:
From P[5] to P[N-2] are 7,8, n * n-8, n * n-9,1,12, n * n- 12, n * n-60. ....
From P[4N] to P[(N-2)*N], it is N*N-(N+3), N*N-(N+4), N+6, N+7,
N*N-(N+7),N*N-(N+8),N+ 10,N+ 1 1 .........
Then fill in the rest of the symmetry.
References:
University of Science and Technology China BBS Station [bbs.ustc.edu.cn]