# LightOJ-1058 Parallelogram Counting

## 题目分析

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 1e3+100;

struct Node{
double x, y;
Node(){}
Node(double a, double b):x(a),y(b){}
bool operator < (const Node temp)const{
if(x != temp.x) return x < temp.x;
else return y < temp.y;
}
}node[maxn], vec[maxn*maxn];

int main(){
int T, n;
scanf("%d", &T);
for(int kase = 1; kase <= T; kase++){
scanf("%d", &n);
for(int i = 0; i < n; i++)
scanf("%lf%lf", &node[i].x, &node[i].y);
int tot = 0;
for(int i = 0; i < n; i++)
for(int j = i+1; j < n; j++)
vec[tot++] = Node((node[i].x + node[j].x)/2.0, (node[i].y + node[j].y)/2.0);
sort(vec, vec+tot);
int cnt = 0, ans = 0;
for(int i = 1; i < tot; i++){
if(vec[i].x == vec[i-1].x && vec[i].y == vec[i-1].y) cnt++;
else{
ans += cnt*(cnt+1)/2;
cnt = 0;
}
}
printf("Case %d: %d\n", kase, ans);
}
return 0;
}

#### 计算几何---判断点是否在线段上

2016-04-07 19:46:10

#### lightoj1058 Parallelogram Counting

2015-12-02 19:00:14

#### 判断几个点是否在一条直线上（计算几何）

2016-08-16 21:39:15

#### UVa 378 - Intersecting Lines

2015-04-20 12:33:26

#### 判断点在有向线段的左边还是右边

2017-09-21 21:39:46

#### lightoj-1058 - Parallelogram Counting

2016-08-14 16:30:37

#### poj1971 Parallelogram Counting

2016-04-23 22:58:04

#### lightoj-1058 - Parallelogram Counting【计算几何】（思维）

2016-08-14 17:17:07

#### Parallelogram Counting

2016-08-18 16:53:49

#### 【lightoj1305】 Area of a Parallelogram

2016-08-25 19:50:58