-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathG.cpp
More file actions
66 lines (44 loc) · 833 Bytes
/
Copy pathG.cpp
File metadata and controls
66 lines (44 loc) · 833 Bytes
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
46
47
48
49
50
51
52
53
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define repx(i, a, n) for(int i = a; i < n; i++)
#define eb emplace_back
struct Point{
int x;
int y;
};
int distance(Point &a, Point &b)
{
return (a.x - b.x)*(a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
bool isTriangleRectangle(Point &a, Point &b, Point &c)
{
int ab = distance(a, b);
int bc = distance(b, c);
int ac = distance(a, c);
return (ab + bc == ac or ab + ac == bc or bc + ac == ab);
}
int main()
{
int n; cin >> n;
vector<Point> points;
rep(i, n)
{
Point p;
cin >> p.x >> p.y;
points.eb(p);
}
int counter = 0;
rep(i, n)
{
repx(j, i + 1, n)
{
repx(k, j + 1, n)
{
if (isTriangleRectangle(points[i], points[j], points[k]))
counter++;
}
}
}
cout << counter << "\n";
}