# ZeroJudge - b604: Center of Symmetry
### 題目連結:https://zerojudge.tw/ShowProblem?problemid=b604
###### tags: `ZeroJudge` `數學` `幾何`
```cpp=
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
#define ERROR 1e-7
#define ROUND(value) ((value) + ERROR > 0 && (value) - ERROR < 0 ? 0 : ((value) < 0 ? int((value) - ERROR) : int((value) + ERROR)))
struct point {
int x, y;
point() {}
point(int X, int Y):x(X), y(Y) {}
bool operator<(const point &other) const {
if (this->x != other.x)
return this->x < other.x;
return this->y < other.y;
}
bool operator>(const point &other) const {
return other < *this;
}
bool operator==(const point &other) const {
return (this->x == other.x && this->y == other.y);
}
bool operator!=(const point &other) const {
return (this->x != other.x || this->y != other.y);
}
} points[10001], target;
istream& operator>>(istream& inputstream, point &target) {
return (inputstream >> target.x >> target.y);
}
int main() {
cin.sync_with_stdio(false), cin.tie(nullptr);
double centerX, centerY, bufferX, bufferY;
bool paired[10001], symmetry;
int amount, x, y, buffer;
while (cin >> amount, amount) {
centerX = centerY = 0.0;
for (int i = 0; i < amount; ++i) {
cin >> points[i];
centerX += points[i].x; centerY += points[i].y;
}
sort(points, points + amount);
centerX /= amount; centerY /= amount;
memset(paired, false, sizeof(paired)); symmetry = true;
for (int i = 0; i < amount; ++i)
if (!paired[i]) {
bufferX = centerX * 2 - points[i].x; bufferY = centerY * 2 - points[i].y;
target = point(ROUND(bufferX), ROUND(bufferY));
buffer = int(lower_bound(points, points + amount, target) - points);
if (buffer == amount || points[buffer] != target) {
symmetry = false;
break;
}
paired[i] = paired[buffer] = true;
}
cout << (symmetry ? "yes" : "no") << '\n';
}
}
```