1 /* 2 暴力:O (n^2) 3 */ 4 #include5 #include 6 #include 7 #include 8 #include 9 using namespace std;10 11 const int MAXN = 1e4 + 10;12 const int INF = 0x3f3f3f3f;13 14 int main(void) //Codeforces Round #183 (Div. 2) A. Pythagorean Theorem II15 {16 int n;17 while (scanf ("%d", &n) == 1)18 {19 int ans = 0;20 for (int i=1; i<=n; ++i)21 {22 for (int j=i; j<=n; ++j)23 {24 if (i * i + j * j > n * n) break;25 int c = sqrt (i * i + j * j);26 if (c <= n && c * c == i * i + j * j) ans++;27 }28 }29 30 printf ("%d\n", ans);31 }32 33 return 0;34 }