Chapter 105: Rubik's Cube Matrix
The Rubik's Cube Matrix, also known as the Magic Cube, is a vertical and horizontal chart.
It refers to an N-order matrix composed of 1~N^2 and N^2 numbers arranged with the same number of rows and columns, and the sum of each row and column and diagonal is equal.
In "Shooting the Condor", Guo and Huang were chased by Qiu Qianren to Black Dragon Pond and hid in Aunt Ying's hut. Yinggu came up with a problem: the numbers 1~9 were filled in a table with three rows and three columns, and the sum of each row, column, and two diagonals was required to be equal. This question stumped Aunt Ying for more than ten years, and Huang Rong answered it at once.
4 9 2
3 5 7
8 1 6
This is the simplest third-order planar Rubik's Cube matrix.
And today's question from Lao Tang is a more difficult fifth-order Rubik's Cube plane matrix.
The difficulty of the calculation, I don't know how much higher it is than the third-order Rubik's Cube matrix.
However, since the Rubik's Cube matrix has been defined by mathematicians, it naturally has a unique set of algorithms.
According to the value of N, it can be divided into three cases.
When N is an odd number, when N is a multiple of 4, when N is an even number!
Lao Tang's problem is to find the 5th-order plane Rubik's cube, and it is obvious that you can apply the operation law that N is an odd number.
Cheng Nuo silently recalled in his mind the filling law of the plane Rubik's cube when N was an odd number.
"When N is an odd number
(1) Put 1 in the middle column of the first row;
(2) The numbers from 2 to n×n are stored according to the following rules:
Walk in a 45° direction, such as to the upper right
Each number is stored in a row minus 1 from the number of rows of the previous number, and the number of columns is minus 1
(3) If the range of the rows and columns is outside the range of the matrix, it is rounded.
For example, if 1 is in the first row, then 2 should be placed in the bottom row, and the number of columns should also be reduced by 1;
(4) If there is already a number in the position determined according to the above rules, or if the previous number is in column n of the first row,
then place the next number below the previous number. (Note (1))
"So, the correct answer should be ......"
Cheng Nuo constructs a grid model in his mind. Soon, 25 numbers were filled in.
Boom~~
In the eyes of the classmates, I saw that Cheng Nuo did not hesitate at all, holding the chalk on the blackboard, and the crumbs were flying. There are no pauses in between, all in one go!
Raising his hands and feet, he reveals an incomparably strong self-confidence.
"Alright, teacher, I'm done. Cheng Nuo turned around, threw the chalk head on the lectern, and said to Old Tang with a smile.
"Okay, let me see, are you filling it in correctly?" Old Tang looked at the filled grid on the blackboard with a curiosity.
15 8 1 24 17
16 14 7 5 23
22 20 13 6 4
3 21 19 12 10
9 2 25 18 11
All correct!!
The position of the 25 numbers is exactly the same as the correct answer.
The sum of each row, each column, and each diagonal is 65!~
Old Tang glanced at Cheng Nuo, who looked as usual, in surprise. Then under the expectant gaze of the whole class, he announced, "Cheng Nuo's answer...... That's right!"
Wow~~
The class was in an uproar.
Sure enough, Cheng Nuo, this guy is still as tough as ever!
It can't be compared, it really can't be compared.
Their brain configuration and Cheng Nuo's brain configuration are simply not at the same level.
Xueba is an existence that is only worthy of being looked up to by scumbags!
Old Tang looked at Cheng Nuo and said, "Since Cheng Nuo is the first student to solve this problem, then my 'special' reward belongs to Cheng Nuo." Cheng Nuo, can you tell us how you solved this problem?"
"No problem. Cheng Nuo nodded, turned around and pointed to the question, "Actually, this question is very simple." ”
This question...... Very simple?
Well, you're a top student, and you have the final say.
The class rolled their eyes.
Cheng Nuo shrugged his shoulders and continued to preach as usual. "Before I talk about this question, I want to tell you about a model called the Rubik's Cube Matrix!"
Why does Cheng Nuo know about the Rubik's Cube Matrix?
It stands to reason that in high school, this knowledge will not be involved.
But who is Cheng Nuo? He's a top student!
One of the characteristics of a top student is that he will never be satisfied with just learning what he has in class!
Do you still remember the large number of books on the world's mathematical problems that Cheng Nuo bought back from the bookstore? This Rubik's Cube matrix was used in the reasoning process of one of the puzzles. Cheng Nuo wrote it down by the way.
Cheng Nuo stood on the podium and explained the three solutions of the Rubik's Cube matrix.
After listening to this theorem, do you think this problem is much simpler? First of all, the number in the middle of the first row must be 1, and the position of the number 2 ......"
The students under the podium were dizzy and unconscious, but Cheng Nuo spoke with relish on the podium.
"Okay, that's all I want to say, thank you!" After speaking, Cheng Nuo walked off the podium.
Bang Bang Bang ~~
The whole class subconsciously applauded.
After Comrade Tang stepped down from the podium, Comrade Tang stood in front of the podium with an embarrassed expression.
Sister, I've finished everything I want to say, what should I say?!
Originally, Comrade Lao Tang wanted to use this topic to draw out the Rubik's Cube matrix and diverge students' thinking before the college entrance examination.
Can ...... now
Belch...... Okay, Cheng Nuo explained the Rubik's Cube Matrix in more detail than me, so I, as a teacher, still don't be ugly.
"Alright. Students, let's take out the set of Hengshui real questions sent last week, and let's talk about that set of test papers. Old Tang coughed awkwardly, and didn't ask his classmates if they understood, so he hurriedly changed the topic.
"Wow, Mu Leng, Cheng Nuo is really amazing. Such a question will be!" Su's small bright eyes were full of little stars.
The corners of Mu Leng's mouth rose slightly, "This is the ...... He's rebellious!"
............
"Alright, class is over. Mu Leng, Cheng Nuo, you two come to the office with me. ”
With the bell of the end of class, Old Tang just finished the last question.
Cheng Nuo and Mu Leng glanced at each other, they were both confused, they didn't know what Lao Tang was looking for him, but they still followed Lao Tang to the office honestly.
When going down the stairs, Cheng Nuo leaned over to Mu Leng's side and whispered with a little worry in his tone, "Sister Leng, did you say that the two of us were found out about falling in love by Old Tang?"
Mu Leng glanced at Cheng Nuo indifferently, and said word by word: "You-say-what!"
Cheng Nuo shrunk his neck and looked sneered, "Just kidding, just kidding." ”
"But, Sister Leng, do you really don't think about the two of us anymore? Look, you are a scholar, I am also a scholar, a scholar is a scholar, and the two of us are a good match. The child born must also be a scholar!" Cheng Nuo said with his fists clenched.
Mu Leng pursed his lips and said ambiguously, "After the college entrance examination, let's talk about this issue." ”
"Okay, I'll wait for you. Cheng Nuo smiled faintly.
..................
Note (1): The algorithm for the other two cases of the Rubik's Cube matrix. (The number of words in the main body has reached 2000 words, this is not the number of water words, this is to help you learn this question!!, please understand the author's good intentions.) )
(2) When N is a multiple of 4
The symmetrical element exchange method is adopted.
First, fill in the matrix from 1 to n× n from top to bottom and from left to right
Then the numbers on the two diagonals of all 4×4 sub-squares of the square matrix are symmetrically exchanged with respect to the center of the large square matrix (note that the number above the diagonal of each submatrix), that is, a(i,j) and a(n+1-i,n+1-j) are exchanged, and the numbers in all other positions remain unchanged. (Or keep the diagonal unchanged, and other positions can be symmetrically swapped)
(3) When N is an even number
When n is an even number (i.e., 4n+2) that is not a multiple of 4: first, the large square is decomposed into 4 odd (2m+1) sub-squares.
According to the above odd-order Rubik's cube, the corresponding values of the 4 sub-squares of the decomposition are assigned
The upper left sub-array is the smallest (i), the lower right sub-array is small (i+v), the lower left sub-array is the largest (i+3v), and the upper right sub-array is the largest (i+2v)
That is, the 4 sub-squares correspond to the element difference v, where v=n*n/4
The four submatrices are arranged from smallest to large: (1), (3), (4), (2)
Then the corresponding elements are exchanged: a(i,j) and a(i+u,j) are exchanged in the same column (j& lt; T-1 or J& gt; n-t+1),
Note where j can be removed from zero.
a(t-1,0) and a(t+u-1,0) and a(t-1,t-1) and a(t+u-1,t-1) are exchanged for two pairs of elements
where u=n/2,t=(n+2)/4 The above exchange equalizes the sum of the elements in each row and column and two diagonals.
............
PS: I've detailed the steps to this extent. If you don't ...... again I can't help it.