

 Task: Mirror trapA mirror trap is a cuboid made of mirrors, the reflecting sides of which are facing the interior of the cuboid. Precisely in the geometric centre of the cuboid there is a miniature laser (whose dimensions we shall neglect). The task is to aim the laser in such a way that the beam travels the longest total distance possible and returns to the laser itself. By total distance we shall denote the sum of distances traveled by the laser beam in each of the three directions parallel to the edges of the mirrors (i.e. we are using the so called Manhattan (city) metric). The dimensions of the trap are even integers. The edges and vertices of the trap, where distinct sides meet, do not reflect the laser beam. Inside the cuboid we shall introduce a cartesian coordinate system. Its axes are parallel to the edges of the trap and the laser shall be placed in the origin. The laser may be aimed at any integer point (a point whose all coordinates are integers) within the trap, the points on the surface of the mirrors included (with the single exception of the laser itself, i.e. the point (0, 0, 0)). TaskWrite a programme which:
InputA single test consists of many mirror traps to be analysed. The first line of the standard input contains a single integer 1 <= K <= 1000, denoting the number of traps to be analysed. In the lines 2 ... K + 1 there are descriptions of the traps, a single per line. The description of the trap consists of three numbers 5 <= x, y, z <= 1000, separated by single spaces. The mirror trap has the dimensions of 2x2y2z.
OutputYour programme should write exactly K lines to the standard output. The ith line should contain a solution for the ith trap: three integers kx, ky, kz, separated by single spaces,  x <= kx <= x,  y <= ky <= y,  z <= kz <= z, (kx, ky, kz) <> (0, 0, 0). Those numbers signify that in the ith trap the laser should be aimed at the point, whose coordinates are (kx, ky, kz).
Should there be a greater number of correct solutions, your programme ought to write out any one of them.
Print friendly version 