Right-angled triangle

3.1

16 votes
Geometry, Algorithms, Polygon Basic, Math, Polygon
Problem

Alice was a bright student of Mathematics. She loved the properties of right-angled triangles. However, she was not able to do her mathematics homework. She is given an integer X. She is interested in finding out the number of right-angled triangles with X as one of its sides. A right-angled triangle can be uniquely determined by its sides. Also, the order of sides does not matter. So a triangle with sides (3, 4, 5) is the same as a triangle with sides (4, 3, 5). 

She suspected that this is not a mathematics problem but rather a programming task. So she asks her friend Bob for help.

Input format

  • The first line contains a single integer T(1T10), the number of test cases.
  • The only line of each test case contains a single integer X(1X1012).

Output format

Print T lines each containing one integer that is the total number of right-angled triangles with X as one of its sides.

Sample Input
3
2
3
5
Sample Output
0 
1 
2 
Time Limit: 2.5
Memory Limit: 256
Source Limit:
Explanation

For the first test case their exists no right-angled triangle with 2 as one of its sides.
For the second test case (3, 4, 5) is the only right-angled triangle with 3 as one of its sides. Note that (4, 3, 5) is not considered separately.
For the third test case (3, 4, 5) and (5, 12 , 13) are valid right-angled triangles.

Editor Image

?