# Pythagorean Theorem II

In mathematics, the Pythagorean theorem — is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:

In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle).

The theorem can be written as an equation relating the lengths of the sides ab and c, often called the Pythagorean equation:

a2 + b2 = c2

where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides.

Given n, your task is to count how many right-angled triangles with side-lengths ab and c that satisfied an inequality 1 ≤ a ≤ b ≤ c ≤ n.

Input

The only line contains one integer n (1 ≤ n ≤ 104) as we mentioned above.

Output

Print a single integer — the answer to the problem.

Examples
Input
5

Output
1

Input
74

Output
35

//把c作为待求量；
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int n,num;
int a,b;
double c;
while(cin>>n)
{
num=0;
for(a=1;a<=n;a++)
for(b=1;b<=n;b++)
{
c=a*a+b*b;
c=sqrt(c);
if(c>n)
break;
else
{
if((c==(int)c)&&((int)c>=b&&b>=a))//在if判断条件内，关系运算符不能连用；
num++;
else
continue;
}

}
cout<<num<<endl;
}
return 0;
}

//把a作为待求量；
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int n;
int b,c;
double a;
int num;
while(cin>>n)
{
num=0;
for(c=1;c<=n;c++)
for(b=1;b<c;b++)
{
a=c*c-b*b;
a=sqrt(a);
if(a==(int)a&&b>=a)
num++;
}
cout<<num<<endl;
}
return 0;
}

• 广告
• 抄袭
• 版权
• 政治
• 色情
• 无意义
• 其他

120