[Home|Training|Problems|Contests|C Language] | [Login|Register] |

Problems Status Rank |
Problem 1127
Laser in Cuboids
Time Limit: 1000ms
Memory Limit: 65536kb Description
As 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). Input
Each line of the input is a test case, which contains three integer a, b and c, 0< a, b, c<10^{6}. The last line of input is “0 0 0”.
Output
For each case, output the number of small cubes the laser passing through.
Sample Input
1 1 3 2 2 3 3 3 3 0 0 0 Sample Output
3 4 3 |

University of Science and Technology of China

Online Judge for ACM/ICPC

Processed in 1.5ms with 1 query(s).

Online Judge for ACM/ICPC

Processed in 1.5ms with 1 query(s).