# New contest from azspcs.net

Yesterday a new contest from azspcs.net started. It will last 3 months, so everyone will have time to participate.

The task is as follows: you need to come up with 2 * 25 squares of size NxN (from 3x3 to 27x27). In the square cells you need to put down the numbers from 1 to N ^ 2 (respectively, "from 1 to 9" for the smallest square and "from 1 to 729" for the largest square), the numbers are not repeated.

Further, for each square, a certain number is considered according to the following rules:

It is necessary to minimize this number (one task) and maximize it (another task). Total 2x25 tasks.

An interesting system of scoring: for each of 25 tasks, the minimum solution found is subtracted from the maximum solution, this is the “result of the player on the task”. Since no one knows the exact solution to the problem (at least for 27x27 for sure), so one point gets the solution that is currently the best among all players. The remaining players receive a percentage of one point, depending on their result. If someone finds a solution better than everything that came before him, he gets one point, and the rest of the players cut points.

If it became interesting - here you are .

The task is as follows: you need to come up with 2 * 25 squares of size NxN (from 3x3 to 27x27). In the square cells you need to put down the numbers from 1 to N ^ 2 (respectively, "from 1 to 9" for the smallest square and "from 1 to 729" for the largest square), the numbers are not repeated.

Further, for each square, a certain number is considered according to the following rules:

- Each pair of numbers from the square is taken;
- For this pair of numbers, a GCD is sought;
- For this pair of numbers, the square of the distance between them is searched, for example, if the first number is written in the 1x1 cell, and the second in the 2x2 cell, then the square of the distance between them is 2 (according to the Pythagorean theorem, the square of the hypotenuse is equal to the sum of the squares of the legs, i.e. 1 + 1 = 2 );
- GCD and the square of the distance are multiplied;
- The results obtained in the previous step are added up for each pair of numbers.

It is necessary to minimize this number (one task) and maximize it (another task). Total 2x25 tasks.

An interesting system of scoring: for each of 25 tasks, the minimum solution found is subtracted from the maximum solution, this is the “result of the player on the task”. Since no one knows the exact solution to the problem (at least for 27x27 for sure), so one point gets the solution that is currently the best among all players. The remaining players receive a percentage of one point, depending on their result. If someone finds a solution better than everything that came before him, he gets one point, and the rest of the players cut points.

If it became interesting - here you are .