Hexagonal Pasture Network#2605

Hexagonal Pasture Network

1 segundo
64 megabytes
Difícil (≈1650)

Farmer John recently acquired some new land to expand his farm. His cows have taken a liking to the hexagonal structure of bee honeycombs, and, ever willing to please his herd, Farmer John has set up a new system of pastures and cowpaths in this format.

The full plot of pastures and cowpaths forms a hexagon with side length (2 \leq k \leq 50). Pastures are conveniently numbered to 3 \cdot k \cdot (k-1) + 1 starting in the bottom left and ending in the upper right, according to the general pattern shown in this illustration for k = 3:

Each pasture is connected to all of its immediate neighbors. If a pasture is on the inside of the hexagon, it is adjacent to exactly six other pastures. For example, in the diagram above, pasture is adjacent to pastures , , , , , and . Pastures on the side (but not at the corners) are adjacent to exactly four other pastures (for example, pasture is adjacent to , , , and ). Pastures at a corner are adjacent to only three other pastures ( is connected to , , and ). The length of any cowpath is , and the distance between two pastures is the length of the shortest path between them.

Farmer John's Holstein cows have been grazing in pasture (1 \leq h \leq 3 \cdot k \cdot (k-1) + 1) for several days and have grown fat and lazy. To get his cows to exercise, Farmer John has placed tasty treats in pastures that are exactly a distance (1 \leq l \leq 2 \cdot k - 2) away from their current location. He guarantees that he has placed at least one treat, but he does not reveal the exact locations.

Help the cows avoid unnecessary running: output the number of possible pastures where treats could be, and then list the pasture numbers in increasing order.

For example, suppose k = 3 and the cows are at pasture . Farmer John says that treats are a distance of away. The possible locations of the treats are pastures , , , , and , as shown below.

Entrada

A single line contains three integers , , and .

Salida

On the first line, print the number of pastures at distance from pasture . On the i+1-th line, print the number of the -th such pasture in increasing order.

Ejemplos

Ejemplo 1

Loading
Loading