Marcus is a mathematician working at the University of Waterloo. Recently, he had been playing with triangles, and as he is a magnificent mathematician, he soon discovered a powerful formula to count right triangles under a certain hypotenuse. Are you able to keep up with Marcus?
More formally, given an integer hypotenuse , Marcus would like you to count the number of non-degenerate triangles with integer legs and a hypotenuse (possibly non-integral) at most . In this case, a triangle is defined as an ordered pair (representing the lengths of its legs) such that and .
Lastly, to ensure the runtime and integrity of your solution, it will be run on test cases.
Your solution will be accepted if it has a relative error of at most . Relative error will be determined using the following formula:
If your answer is and the correct answer is , then your answer will be considered correct if
It is guaranteed that the output data has exactly the correct answer.
Constraints
For all subtasks:
Subtask 1 [10%]
Subtask 2 [10%]
Subtask 3 [20%]
Subtask 4 [60%]
Input Specification
The first line will contain , the number of test cases.
The next lines will each contain an integer, the value of for that test case.
Output Specification
Output the answer to each test case on a separate line.
Note: while the correct answer is always an integer, the float
checker is used to determine if your solution is correct, so outputting a floating-point value is OK.
Sample Input
10
1
2
3
4
5
6
7
8
9
10
Sample Output
0
1
4
8
15
22
30
41
54
69
Explanation
Here are the answers for the first few test cases:
For , there are no triangles that satisfy the requirement.
For , the triangle that satisfies the requirement is .
For , the triangles that satisfy the requirement are , along with the one that satisfies .
For , the triangles that satisfy the requirement are , along with the ones that satisfy .
Comments