Blocks to Cubes
Practice
3.1 (9 votes)
Mathematics
Open
Approved
Easy
Greatest common divisor
Problem
17% Success 11648 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Bholu the Pandit on this New Year wanted to divide his Cuboidal Packaging block into cubes. But he loves uniformity so he asks you to divide it such a way that all the cubes are of same size and volume of individual cube is as large as possible.

Note: He will utilize whole volume i.e volume of cuboid before dividing is same as sum of volume of all the cubes.

Input
The first input line contains an integer T, the number of testcases. Each testcase consist of single line which consist of 3 space separated integers a, b & c representing length, breadth and height of the Cuboidal block.

Output
For each testcase you need to output 2 space separated integers, the length of side of the cube and the number of cubes which could be formed out of this cuboidal packaging block. As the number of cubes which could be made could be a large number so just output the answer modulus 109+7 (1000000007).

Constraints
1T1000
1a,b,c109

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
512 votes
Tags:
OpenApprovedEasy
Points:30
290 votes
Tags:
ReadyBit manipulationApprovedEasy-Medium
Points:20
12 votes
Tags:
Greatest common divisorAlgorithmsGCDMathNumber Theory