#P2931. Magic Bracelet Unique-Sum Property

    ID: 16189 Type: Default 1000ms 256MiB

Magic Bracelet Unique-Sum Property

Magic Bracelet Unique-Sum Property

Bessie received a magic bracelet made of the rarest black pearls for her favorite holiday. On each pearl a small number is etched. When the bracelet is bent around a point, some pearls will "correspond" to each other. For each bending, Bessie computes progressive sums for the pearls on the top and bottom. That is, if the pearls on the top are a1, a2, ... , ak then the ONE-sum is \(a_1\), the TWO-sum is \(a_1+a_2\) mod \(M\), the THREE-sum is \(a_1+a_2+a_3\) mod \(M\), and so on. Similarly for the bottom row. The unique-sum property requires that in every possible bending the progressive sum computed on the top never equals the progressive sum computed on the bottom (when compared modulo \(M\)).

For example, if \(M=3\) and the bracelet has \(N=6\) pearls etched with the numbers 0, 1, 0, 2, 1, 0 (represented as >0-1-0-2-1-0<), then when laid out in the various possible ways some pairs of progressive sums (ONE-sum, TWO-sum, etc.) for top and bottom are computed. In each bending the two corresponding sums (top and bottom) are different mod \(M\).

Bessie has heard that all magic bracelets have this unique-sum property. She now wonders: given a value of \(M\) (where \(2 \le M \le 100\)), what is the longest possible bracelet (with at most 20,000 pearls) whose engraved numbers maintain the unique-sum property?

Output-Only Problem: You are provided with 15 input files. Your task is to output a valid bracelet configuration (a sequence of numbers) for a given \(M\).

Scoring: Your score for each test case is computed as \(score = \text{int}(10 \times \sqrt{\frac{YOURS}{BEST}})\), where YOURS is the length of your bracelet solution and BEST is the length of the best solution among all contestants.

Feedback: Upon submission, your output will be checked for both correct format and validity (i.e. whether it satisfies the required numerical properties) and you will be informed of the results.

inputFormat

The input consists of a single integer \(M\) (2 \(\le\) M \(\le\) 100) given on one line.

Note: This is an output-only problem. In the actual contest, you will download 15 input files.

outputFormat

Output a single line containing a sequence of integers separated by spaces. The sequence represents the numbers etched on the pearls of the bracelet. The length of the sequence must be at most 20,000 and must satisfy the bracelet's unique-sum property as described.

sample

3
0