- All Contests
- ProjectEuler+
- Project Euler #94: Almost equilateral triangles

# Project Euler #94: Almost equilateral triangles

# Project Euler #94: Almost equilateral triangles

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

It is easily proved that no equilateral triangle exists with integral length sides and integral area. However, the *almost equilateral triangle* has an area of square units.

We shall define an *almost equilateral triangle* to be a triangle for which two sides are equal and the third differs by no more than one unit.

Find the sum of the perimeters of all *almost equilateral triangles* with integral side lengths and area and whose perimeters do not exceed .

**Input Format**

First line contains , denoting the number of testcases.

Next lines contains .

**Constraints**

**Output Format**

Output lines corresponding to test cases.

**Sample Input**

```
2
17
51
```

**Sample Output**

```
16
66
```

**Explanation**

For first test case we get perimeter .

Second test case there is another triangle whose area is units.