forked from sitz/UVa-Online-Judge
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path10575.cpp
52 lines (48 loc) · 766 Bytes
/
10575.cpp
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
#include <bits/stdc++.h>
using namespace std;
int x[1000], y[1000];
int n;
int test(int, int);
int d(int, int);
int main()
{
int i, j, k, ax;
for (j = 1;; j++)
{
scanf("%d", &n);
if (!n)
{
break;
}
for (i = 0; i < n; i++)
{
scanf("%d %d ", x + i, y + i);
}
ax = 0;
for (i = 0; i < n; i++)
{
ax += test(i, i + 1) + test(i, i + 2);
}
printf("Polygon #%d has %d symmetry line(s).\n", j, ax / 2);
}
}
int test(int a, int b)
{
int i, j, k;
for (i = 1; i < n; i++)
{
if (d(a, a + n - i) != d(b, b + i))
{
return 0;
}
if (d(a, b + i) != d(b, a + n - i))
{
return 0;
}
}
return 1;
}
int d(int c, int d)
{
return (x[c % n] - x[d % n]) * (x[c % n] - x[d % n]) + (y[c % n] - y[d % n]) * (y[c % n] - y[d % n]);
}