#P11555. Inheritance Land Distribution

    ID: 13645 Type: Default 1000ms 256MiB

Inheritance Land Distribution

Inheritance Land Distribution

In the kingdom’s territory, there is a straight road of length $n$ kilometers. Adjacent to the road is a vast forest. The king, deeply concerned about nature protection, decided to declare the forest a nature reserve. However, his three sons opposed this decision because they wished to inherit the land.

To ensure that none of his sons inherit the protected land, the king devised the following conditions for allocating the remaining land as square parcels to his three sons:

  • Each parcel must be a square with a positive integer side length. Let the side lengths be $a$, $b$, and $c$ respectively.
  • The sum of the three side lengths must exactly cover the road, i.e., $a+b+c=n$.
  • The parcels must be strictly increasing in size: $a<b<c$.
  • The total area $a^2+b^2+c^2$ should be minimized.

Given $n$, determine the values of $a$, $b$, and $c$ that satisfy these conditions. If no valid distribution exists, output -1.

inputFormat

Input consists of a single integer nn (n6n \geq 6) representing the length of the road.

outputFormat

Output three space-separated integers aa, bb, and cc that represent the side lengths of the square parcels that should be assigned to the three sons. If no valid distribution exists, output -1.

sample

6
1 2 3