#t46. 勾股数计数

勾股数计数

Counting Pythagorean Triples

Problem Description

Pythagorean triples are a very interesting mathematical notion. Three positive integers a,b,ca, b, c satisfying a2+b2=c2a^2 + b^2 = c^2 with 1≤a≤b≤c1 \le a \le b \le c form a Pythagorean triple (a,b,c)(a, b, c). Can you write a program to count how many such Pythagorean triples satisfy c≤nc \le n?

Input Format

One line containing a positive integer nn. It is guaranteed that 1≤n≤10001 \le n \le 1000.

Output Format

Output one line containing an integer CC, the number of Pythagorean triples satisfying the condition.

Sample Input

Sample Input 1

5

Sample Input 2

13

Sample Output

Sample Output 1

1

Sample Output 2

3

Sample Explanation

For the first sample, the input is 55, meaning we need to find all Pythagorean triples with c≤5c \le 5. By enumerating all possible combinations of a,b,ca, b, c satisfying a2+b2=c2a^2 + b^2 = c^2 and 1≤a≤b≤c≤51 \le a \le b \le c \le 5, only (3,4,5)(3, 4, 5) works, since 32+42=9+16=25=523^2 + 4^2 = 9 + 16 = 25 = 5^2. So the output is 11.

Constraints

1≤n≤10001 \le n \le 1000