Problem of the day
Ninja is planning to build a new apartment but he wants an apartment in the shape of a rectangle whose length is greater than the breadth of the rectangle. Also, the difference between the length and breadth should be minimum for the area of the apartment.
So your task is to print the length and breadth of the rectangle. You are provided with the ‘AREA’ of the region in which the apartment is to be built.
Example:
Suppose given ‘AREA’ is ‘6’. So, possible combinations are [ [ 1, 6 ], [ 2, 3 ], [ 3, 2 ], [ 6, 1 ] ]. We can’t choose [ 1, 6 ], [ 2, 3 ] as in this case breadth is greater than length.
So, we choose [ 3, 2 ] over [ 6, 1 ] as the difference between | 3 - 2 | < | 6 - 1 | so we return | 3, 2 | as the answer.
Note:
You are not required to print anything explicitly. It has already been taken care of. Just implement the function.
2
12
8
4 3
4 2
In the first test case,
Given ‘AREA’ is ‘12’ so possible combinations are [ [ 1, 12 ], [ 2, 6 ], [ 3, 4 ], [ 4, 3 ], [ 6, 2 ], [ 12, 1 ] ]. We can’t choose [ 1, 12 ], [ 2, 6 ], [ 3, 4 ] as in this case breadth is greater than length.
We choose [ 4, 3 ] over [ 6, 2 ] and [ 12, 1 ] as the difference between | 4 - 3 | < | 6 - 2 | and | 4 - 3 | < | 12 - 1 | so we print | 4, 3 | as the answer.
In the second test case,
Given ‘AREA’ is ‘8’ so possible combinations are [ [ 1, 8 ], [ 2, 4 ], [ 4, 2 ], [8, 1 ] ]. We cant choose [ 1, 8 ], [ 2, 4 ] as in this case breadth is greater than length.
We choose [ 4, 2 ] over [ 8, 1 ] as the difference between | 4 - 2 | < | 8 - 1 | so we print | 3, 2 | as the answer.
2
17
16
17 1
4 4
In the first test case,
Given ‘AREA’ is ‘17’ so possible combinations are [ [ 1, 17 ], [ 17, 1 ] ]. We can’t choose [ 1, 17 ] as in this case breadth is greater than length.
We choose [ 17, 1] and so we print | 17, 1 | as the answer.
In the second test case,
Given ‘AREA’ is ‘16’ so possible combinations are [ [ 1, 16 ], [ 2, 8 ], [ 4, 4], [ 8, 2 ], [16, 1 ] ]. We cant choose [ 1, 16 ], [ 2, 8 ] as in this case breadth is greater than length.
We choose [ 4, 4 ] over [ 8, 2 ] and [16,1] as the difference between | 4 - 4 | < | 8 - 2 | so we print | 4, 4 | as the answer.