P16247 [Lanqiao Cup 2026 NOI Qualifier Graduate Group] Magic Matrix Energy Value
Description
For an $n \times n$ magic matrix $M$, we define its energy value calculation rules as follows.
1. **Base energy**: The base energy of the element at position $(i, j)$ is $i \times j \times (i + j)$.
2. **Diagonal bonus**: The energy value of elements on the main diagonal (that is, at $(1,1), (2,2), \ldots, (n,n)$) is doubled.
3. **Boundary penalty**: The energy value of elements on the matrix boundary (that is, row $1$, row $n$, column $1$, column $n$) is halved. If an element lies on multiple boundaries at the same time, its energy value is still halved only once.
4. **Center reward**: If $n$ is odd, the energy value of the element at the center position $\left(\frac{n+1}{2}, \frac{n+1}{2}\right)$ is increased by an additional $100$.
**Important reminder**: When a position satisfies multiple conditions, you must strictly calculate in the above order: first compute the base energy, then apply the diagonal bonus, then apply the boundary penalty, and finally apply the center reward.
The total energy value of the matrix is the sum of the energy values of all positions.
Example 1: The complete calculation process for a $2 \times 2$ matrix is as follows.
- Position $(1,1)$: Base energy $1 \times 1 \times 2 = 2$, doubled on the main diagonal to $4$, boundary penalty $\div 2 = 2$, since $n$ is even there is no center reward, energy value $= 2$.
- Position $(1,2)$: Base energy $1 \times 2 \times 3 = 6$, not on the main diagonal so no bonus, boundary penalty $\div 2 = 3$, since $n$ is even there is no center reward, energy value $= 3$.
- Position $(2,1)$: Base energy $2 \times 1 \times 3 = 6$, not on the main diagonal so no bonus, boundary penalty $\div 2 = 3$, since $n$ is even there is no center reward, energy value $= 3$.
- Position $(2,2)$: Base energy $2 \times 2 \times 4 = 16$, doubled on the main diagonal to $32$, boundary penalty $\div 2 = 16$, since $n$ is even there is no center reward, energy value $= 16$.
Total energy value: $2 + 3 + 3 + 16 = 24$.
Example 2: The complete calculation process for a $3 \times 3$ matrix is as follows.
- Position $(1,1)$: Base energy $1 \times 1 \times 2 = 2$, doubled on the main diagonal to $4$, boundary penalty $\div 2 = 2$, not the center so no reward, energy value $= 2$.
- Position $(1,2)$: Base energy $1 \times 2 \times 3 = 6$, not on the main diagonal so no bonus, boundary penalty $\div 2 = 3$, not the center so no reward, energy value $= 3$.
- Position $(1,3)$: Base energy $1 \times 3 \times 4 = 12$, not on the main diagonal so no bonus, boundary penalty $\div 2 = 6$, not the center so no reward, energy value $= 6$.
- Position $(2,1)$: Base energy $2 \times 1 \times 3 = 6$, not on the main diagonal so no bonus, boundary penalty $\div 2 = 3$, not the center so no reward, energy value $= 3$.
- Position $(2,2)$: Base energy $2 \times 2 \times 4 = 16$, doubled on the main diagonal to $32$, not on the boundary so no penalty, center reward $+100 = 132$, energy value $= 132$.
- Position $(2,3)$: Base energy $2 \times 3 \times 5 = 30$, not on the main diagonal so no bonus, boundary penalty $\div 2 = 15$, not the center so no reward, energy value $= 15$.
- Position $(3,1)$: Base energy $3 \times 1 \times 4 = 12$, not on the main diagonal so no bonus, boundary penalty $\div 2 = 6$, not the center so no reward, energy value $= 6$.
- Position $(3,2)$: Base energy $3 \times 2 \times 5 = 30$, not on the main diagonal so no bonus, boundary penalty $\div 2 = 15$, not the center so no reward, energy value $= 15$.
- Position $(3,3)$: Base energy $3 \times 3 \times 6 = 54$, doubled on the main diagonal to $108$, boundary penalty $\div 2 = 54$, not the center so no reward, energy value $= 54$.
Total energy value: $2 + 3 + 6 + 3 + 132 + 15 + 6 + 15 + 54 = 236$.
Now, please compute the total energy value of the $13 \times 13$ magic matrix.
Input Format
N/A
Output Format
This is an output-only fill-in-the-blank problem. You only need to calculate the result and submit it. The result of this problem is an integer. When submitting the answer, only fill in this integer; any extra content will result in no score.
Explanation/Hint
Translated by ChatGPT 5