标签:
1 /*
2 暴力:O (n^2)
3 */
4 #include <cstdio>
5 #include <algorithm>
6 #include <cstring>
7 #include <cmath>
8 #include <vector>
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 II
15 {
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 }
暴力 Codeforces Round #183 (Div. 2) A. Pythagorean Theorem II
标签:
原文地址:http://www.cnblogs.com/Running-Time/p/4556853.html