http://acm.hdu.edu.cn/showproblem.php?pid=5533
暴力跑出所有可能边的长度,然后看有没有出现n次的长度,符合题意,可以不用sqrt算具体的长度,容易出现精度问题。
#include<bits/stdc++.h>
#define _rep(i,a,b) for( int i=(a); i<=(b); ++i)
#define _down(i,a,b) for( int i=(a); i>=b; i--)
using namespace std;
const int mx = 1e5 + 7;
int n;
struct node {
int x, y;
} a[1000];
int cnt(int v, int c) {
int ans = (a[v].x - a[c].x) * (a[v].x - a[c].x) + (a[v].y - a[c].y) * (a[v].y - a[c].y);
return ans;
}
void solve() {
map<int, int> mp;
scanf("%d", &n);
_rep(i, 1, n) {
scanf("%d%d", &a[i].x, &a[i].y);
}
int ok = 0;
_rep(i, 1, n - 1) ok += i;
vector<int> vc;
_rep(i, 1, n) {
_rep(j, i + 1, n) {
int li = cnt(i, j);
vc.push_back(li);
mp[li]++;
}
}
for(auto c : vc) {
if(mp[c] == n) {
puts("YES");
return;
}
}
puts("NO");
}
signed main() {
int t;
scanf("%d", &t);
while(t--) solve();
return 0;
}