Large Square solution codechef
Read problem statements in Mandarin Chinese and Bengali.
You are givenidentical squares, each with side length . All the squares have their sides parallel to the and . That is, the squares are not tilted. You have to take several (possibly, zero or all) squares and rearrange them to obtain a mega square. The mega square can’t have any gap in the enclosed region or have overlapping squares. Also, you cannot rotate any square.
Output the side length of the largest mega square that you can obtain.
Input Format Large Square solution codechef
- The first line of input contains a single integer denoting the number of test cases. The description of test cases follows.
- The first and only line of each test case contains two space-separated integers .
For each test case, print a single line containing one integer – the side length of the largest square you can obtain.
Constraints Large Square solution codechef
Sample Input 1
5 3 2 5 3 16 18 11 8 8 6
Sample Output 1 Large Square solution codechef
2 6 72 24 12
Test case: You can choose just one square to form the mega square. So the side length will be .
Test case: You can choose squares to form a mega square with side-length .