Barbells
Time limit2sMemory limit512 MB
Split the weights 1 through n into three groups of equal total weight, or report that no such split exists.
- Level
Medium5 of 10
- Topics
- Math, Greedy, Implementation, Combinatorics
- Solved
- No attempts yet
Problem
Vanya, Seryozha and Dima like physical exercise. Above all they like lifting heavy things. The three have been doing weightlifting for a long time and have already collected a set of barbells for training. This set consists of barbells with distinct integer weights from 1 to .
Not long ago the three found a new gym and decided to move all their barbells there. Since they enjoy lifting them so much, each of them wants to carry as much weight as possible. But the three are very honest, so they decided to split the total weight equally.
Help the athletes divide the set of barbells with weights into three parts of equal weight.
Input
The input file contains a single integer (), the number of barbells.
Output
For each athlete, output the set of barbells that he has to carry to the new gym. The sets are output as follows. On the first line, output the number of barbells in the set. Then, on the second line, output the weights of the barbells separated by spaces.
If the barbells cannot be split into three sets of equal weight, output <<Impossible>>.
If several solutions exist, you may output any of them.