标签:
//234ms
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
const int maxn = 2000 + 10;
struct Point{
int x,y;
}p[maxn];
long long q[maxn*maxn];
int main(){
int n;
scanf("%d",&n);
for(int i = 0 ; i < n ; ++i){
scanf("%d%d",&p[i].x,&p[i].y);
}
int cnt = 0;
memset(q,-1,sizeof(q));
for(int i = 0 ; i < n ; ++i){
for(int j = i + 1 ; j < n ; ++j){
long long k =((long long) p[i].x + p[j].x)*1E9*2 + (p[i].y) + p[j].y;
q[cnt++] = k;
}
}
sort(q , q + cnt);
int k,ans = 0;
for(int i = 0 ; i < cnt - 1 ;++i){
k = 1;
while(i < cnt && q[i] == q[i + 1]){
++i;++k;
}
ans += k * (k - 1) / 2;
}
printf("%d\n",ans);
return 0;
}
//2214ms
#include<cstdio>
#include<map>
using namespace std;
struct Point{
int x,y;
Point(int a = 0,int b = 0):x(a),y(b){}
}p[2000 + 10];
map<long long,int > m;
int main(){
int n;
scanf("%d",&n);
for(int i = 0 ; i < n ; ++i){
scanf("%d%d",&p[i].x,&p[i].y);
}
for(int i = 0 ; i < n ; ++i){
for(int j = i + 1 ; j < n ; ++j){
long long k =((long long) p[i].x + p[j].x)*1E9*2 + (p[i].y) + p[j].y;
if(m.find(k) == m.end() ){
m[k] = 1;
}else ++m[k];
}
}
map<long long,int>::iterator itm;
int ans = 0;
for(itm = m.begin(); itm != m.end();++itm){
int n = itm -> second;
ans += n * (n - 1) / 2;
}
printf("%d\n",ans);
return 0;
}
[2016-04-15][codeforces][660][D][Number of Parallelograms]
标签:
原文地址:http://www.cnblogs.com/qhy285571052/p/7c0e4bdf3744c4bab7f02dc1547fc831.html