- All Contests
- ProjectEuler+
- Project Euler #85: Counting rectangles

# Project Euler #85: Counting rectangles

# Project Euler #85: Counting rectangles

_{This problem is a programming version of Problem 85 from projecteuler.net}

By counting carefully it can be seen that a rectangular grid measuring 3 by 2 contains eighteen rectangles:

For each testcase an integer *target* would be given . Consider all the rectangular grids such that the *number* of rectangles contained in the grid is *nearest* to *target* . Out of all such rectangular grids output the *area* of the rectangular grid having the *largest* area.

**Input Format**

First line contains denoting the number of testcases.

The following lines contain an integer .

**Constraints**

**Output Format**

For each testcase print the area of the desired rectangular grid .

**Sample Input**

```
2
18
2
```

**Sample Output**

```
6
2
```

**Explanation**

**Case1:** A grid contains 18 rectangles.

**Case2:**

is 2 . The grid contains rectangle and the grids and contain rectangles each.

All other rectangular grids contain more than rectangles.

Hence The set of grids containing the number of rectangles nearest to are , , .

Out of these and are the grids having the largest area equal to .

Hence is the answer as it is the largest area in the set of rectangular grids being considered.