Buy Rectangular Field

0

0 votes
Problem

As soon as Aditya joined college, he realised that he is unable to cope up with the college studies and decided to quit college and buy a rectangular field so that he can grow rice and sell them to earn his living.

The field that Adiya will be buying has a fixed Area A and he has to decide on the length and breadth of the rectangle. He knows that the field with minimum non negative difference between length and breadth is most optimal for growing rice. 

As you know that Aditya is weak in mathematics, please help him to find the minimum non negative difference between length and breadth. 

Input: 

The first line contains an integer T (1≤T≤100) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer A ( 1≤A≤10^9 ) — the area of the rectangle field.

Output:

For each test case, print the minimum absolute difference between length and breadth.

Note: Print the absolute difference between length and breadth.

 

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Sample test 1 - Optimal length is 1 and optimal breadth is 1 

Sample test 2 - Optimal length is 7 and optimal breadth is 1 

Sample test 3 - Optimal length is 4 and optimal breadth is 3

Sample test 4 - Optimal length is 5 and optimal breadth is 5

Sample test 5 - Optimal length is 10 and optimal breadth is 5

 

Editor Image

?