Pythagorean Triplets

5

1 votes
Mathematics, Medium, Open, Approved, Mathamatics
Problem

Pythagorean triplet (a,b,c) satisfies:
enter image description here

You will be given an integer N. You have to count how many triplets a,b,c exist such that
1 <= a <= b <= c <= N.

Input:
First line contains T, the number of testcases. Each testcase consists of only one integer in one line.

Output:
For each testcase, print the required answer.

Constraints:
1 <= T <= 100
1 <= N <= 10^6

Time Limit: 3
Memory Limit: 256
Source Limit:
Explanation

In first testcase, only one triplet ie. (3,4,5) In second testcase, two triplets ie. (3,4,5),(6,8,10).

Editor Image

?