#P6955. Voxel Figure Projections
Voxel Figure Projections
Voxel Figure Projections
You are given three positive integers a, b and c representing the areas of the orthogonal projections of a figure F onto the Oxy, Oxz and Oyz planes respectively.
Your task is to construct a figure F consisting of one or more voxels (unit cubes) whose coordinates are given by triples of integers \((x,y,z)\) (each voxel corresponds to the unit cube \([x,x+1]\times[y,y+1]\times[z,z+1]\)). The figure must satisfy:
- The projection of F onto the Oxy plane (i.e. ignoring z) has exactly a unit cells.
- The projection onto the Oxz plane (ignoring y) has exactly b unit cells.
- The projection onto the Oyz plane (ignoring x) has exactly c unit cells.
If such a figure exists, output any valid description of the figure. Otherwise, output -1
.
Hint: One strategy is to construct a rectangular box of dimensions \(X\times Y\times Z\), because the projection areas will then be \(X\times Y = a\), \(X\times Z = b\) and \(Y\times Z = c\). Observing that \(X^2 = \frac{a\cdot b}{c}\), a solution exists if and only if \(\frac{a\cdot b}{c}\) is a perfect square and divides a and b appropriately.
inputFormat
The input consists of a single line containing three space-separated positive integers a, b, and c.
outputFormat
If a valid figure exists, first output a line containing an integer n, the number of voxels used. Then output n lines, each containing three integers x, y, and z (0-indexed) describing the position of a voxel.
If no valid figure exists, output a single line with -1
.
sample
2 2 1
2
0 0 0
1 0 0
</p>