1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <cmath>
using namespace std;

bool isInt(float n)
{
  if(round(n)==n) return true;
  else return false;
}
int power(int n)
{
  return n*n;
}
float diag(int a,int b,int h)
{
  return sqrt(power(a)+power(b)+power(h));
}

int main() 
{
  int n, counter=0;
  cin>>n;
  float m = static_cast<float>(n);
  for(int i=1;i<=n;i++)
  {
    bool toBreaki = false;
    for(int j=i;j<=n;j++)
    {
      bool toBreakj = false;
      for(int k=1;k<=n;k++)
      {
        float a = diag(i,j,k);
        if(k==1&&a>=m) toBreakj=true;
        if(k==1&&j==i&&a>=m) toBreaki=true;
        if(a>m) break;
        if(isInt(a)&&a<=m) counter++;
        if(a==m) break;
      }
      if(toBreakj) break;
    }
    if(toBreaki) break;
  }
  cout<<counter;
    return 0;
}