Cutting Rectangles
Submissions: 1799   Accuracy:


  Difficulty: Easy   Marks: 2

Given a rectangle of dimensions a X b find the minimum number (n) of identical squares of maximum side that can be cut out from that rectangle so that no residue remains in the rectangle. Also find the dimension k of that square.

The first line of the input contains an integer 'T' denoting the number of testcases. Then T test cases follow. Each test case consits of a single line containing two space separated integers a and b denoting the dimensions of the rectangle.

For each test case print n and k (space separated ) in a new line.

1 <= T <= 100
1 <= a,b <= 109

2 4
3 6
2 8

2 2
2 3
4 2

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Hardik Gulati
Author: Mukesh Kumar 5

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.