#P15513. [BalticOI 2003] Table (Day 1)
[BalticOI 2003] Table (Day 1)
Description
For the given integer , build a square table with rows and columns , filled with decimal digits, with the following restriction: the -digit numbers formed by the digits in each table row (from left to right), each table column (from top to bottom) and each main diagonal (from top to bottom) must be multiples of , must not start with the digit and must be unique within the table.
For example, a valid table for is
The following tables are not valid for :
because ;
because the numbers in the last column and on one of the main diagonals start with the digit ;
because the number is present twice in the table.
It is not always possible to solve this task. For example, the task is unsolvable for .
Input Format
You are given ten test files , each containing one value of .
Output Format
You must find a valid table for each test case and write it into the corresponding output. The first line must contain , the number of rows and columns in the table. The -st line of the output must contain the elements of the -th row of the table as digits, separated by spaces.
2
3
2 3 4
5 6 6
8 2 0
Hint
Remark
It is known that there will be at least one solution for each given test input.
Grading
You will score points for a test case if there is no output for this test case or if any of the conditions given above are not met.
Otherwise your score for the test case is calculated from the formula
$$\text{maximum points for the test case} \times \frac{N _ {\text{least among contestants}}}{N _ {\text{yours}}}$$rounded down to the nearest integer value. Therefore, you should try to find a valid table with the least possible size, within the conditions given above.
Please note that the output for this task is not unique. Also, the grading was relative: the score of each contestant depended on how well other contestants had solved the same test case. For some of the test cases, it is not known whether the tables provided here are indeed the smallest possible. Thus, the output files basically only prove that the required output indeed exists for each given test case.
京公网安备 11011102002149号