Laser in Cuboids
Time Limit: 1000ms
Memory Limit: 65536kb
DescriptionAs we know, a cuboid (rectangular solid) has three mutually perpendicular edges: a, b, c. When a, b and c are all integer, the cuboid can be regarded as a×b×c small cubes gluing together; each of the small cube is 1×1×1.
Now, as in the above figure, there is a laser beam from one vertex to its diagonal opposite vertex. The width of the laser is negligible, but we care about how many small cubes the laser passes through.
Given the integer length of the three edges of the cuboid, your job is to work out how many small cubes the laser passes through (not just contact with its edges or vertices).
InputEach line of the input is a test case, which contains three integer a, b and c, 0< a, b, c<106. The last line of input is “0 0 0”.
OutputFor each case, output the number of small cubes the laser passing through.
1 1 3 2 2 3 3 3 3 0 0 0
3 4 3