1353 - Dartboard
Time Limit : 2 Second
Memory Limit : 256 MB
- A dartboard is a disc divided into n segments, with each segment labeled with a distinct positive integer between 1 and n. That integer indicates the score for hitting the segment. To make the game more interesting, the arrangement of numbers is chosen in such a way that the risk is maximized. The risk is estimated based on the differences in scores of adjacent segments.
We're studying the following 'double-layered' structure of segments in this problem:
i.e., n is always even, and we split the disc into two layers of n/2 parts along the circumference. We enumerate the segments in the following manner: the first segment is some outer segment, the second segment is the corresponding inner segment, the third segment is some adjacent outer segment, etc. An example of this enumeration is shown on the picture above.
The total risk is defined as the sum of squared differences between the scores of adjacent segments. If the value assigned to segment i is ai, then the risk is:
(we assume an+1=a1 and an+2=a2 in this formula).
You are to place the numbers from 1 through n into the segments in such a way that the total risk R is maximized.
- The input file contains an integer T means there are T cases followed.
The next T lines: there is an even integer n (6 ≤ n ≤ 100) in each line.
- Output the MAX(R);
- sample input
2 10 6
- sample output
- When n equals to 10, “ 2 9 7 4 6 5 3 8 10 1”is one of the solutions. It makes R maximized(MAX(R)=461).
- Hust Monthly 10.04.05/木瓜仙人