You are given n points on a plane. All the points are distinct and no three of them lie on the same line. Find the number of parallelograms with the vertices at the given points.

Input

The first line of the input contains integer n (1 ≤ n ≤ 2000) — the number of points.

Each of the next n lines contains two integers (xi, yi) (0 ≤ xi, yi ≤ 109) — the coordinates of the i-th point.

Output

Print the only integer c — the number of parallelograms with the vertices at the given points.

Sample Input
4
0 1
1 0
1 1
2 0
Output
1
题意:

给你n个点的坐标,问这n个点能形成多少个不相同的平行四边形?

思路:

(1) 根据平行四边形的性质,两条对角线相交于一点,所以可以将这n个点两两连接并找出它们的中点并记录下来。

(2) 然后根据这些中点来判断有多少个平行四边形,因为只要有两个中点重合,那么就能确定一个平行四边形。

(3) 所以先找出重合中点的个数s,那么它们可以组成的平行四边形个数为C(s,2)。将它们求和即可。

#include<bits/stdc++.h>
using namespace std;
struct node
{
int x,y;
}a[];
int com(int n,int m)
{
int i,s=;
for(i=;i<=m;i++)
s=s*(n+-i)/i;
return s;
}
int main()
{
int n,i,j,s=;
map<pair<int,int>,int>ma;
map<pair<int,int>,int>::iterator it;
cin>>n;
for(i=;i<=n;i++)
scanf("%d%d",&a[i].x,&a[i].y); for(i=;i<=n-;i++)
for(j=i+;j<=n;j++)
ma[make_pair(a[i].x+a[j].x,a[i].y+a[j].y)]++; for(it=ma.begin();it!=ma.end();it++)
s=s+com(it->second,); printf("%d\n",s);
return ;
}

【CodeForces 660D】Number of Parallelograms(n个点所能组成的最多平行四边形数量)的更多相关文章

  1. CodeForces 660D Number of Parallelograms

    枚举两点,确定一条线段,计算每条线段的中点坐标. 按线段中点坐标排个序.找出每一种坐标有几个. 假设第x种坐标有y个,那么这些线段可以组成y*(y-1)/2种平行四边形. 累加即可. #include ...

  2. codeforce 660D Number of Parallelograms

    题意:询问多少个矩形. 统计横纵坐标差,放进vector中 #include<cstdio> #include<cstring> #include<iostream> ...

  3. Number of Parallelograms CodeForces - 660D (几何)

    Number of Parallelograms CodeForces - 660D You are given n points on a plane. All the points are dis ...

  4. codeforces 660D D. Number of Parallelograms(计算几何)

    题目链接: D. Number of Parallelograms time limit per test 4 seconds memory limit per test 256 megabytes ...

  5. Educational Codeforces Round 11 D. Number of Parallelograms 暴力

    D. Number of Parallelograms 题目连接: http://www.codeforces.com/contest/660/problem/D Description You ar ...

  6. Number of Parallelograms(求平行四边形个数)

    Number of Parallelograms time limit per test 4 seconds memory limit per test 256 megabytes input sta ...

  7. D. Number of Parallelograms

    D. Number of Parallelograms 原题链接 time limit per test 4 seconds memory limit per test 256 megabytes Y ...

  8. D. Number of Parallelograms 解析(幾何)

    Codeforce 660 D. Number of Parallelograms 解析(幾何) 今天我們來看看CF660D 題目連結 題目 給你一些點,求有多少個平行四邊形. 前言 @copyrig ...

  9. 14.4.7 Configuring the Number of Background InnoDB IO Threads 配置 后台InnoDB IO Threads的数量

    14.4.7 Configuring the Number of Background InnoDB IO Threads 配置 后台InnoDB IO Threads的数量 InnoDB 使用bac ...

随机推荐

  1. DevExpress 14.2 批量汉化

    1.下载DevExpress_.NET_Localization_Resources_14.2汉化包 2.解压后将zh-CN或zh-CHS复制到安装目录如D:\Program Files (x86)\ ...

  2. cf1064E. Dwarves, Hats and Extrasensory Abilities(二分 交互)

    题意 题目链接 \(n\)次操作,每次你给出一个点的坐标,系统会返回该点的颜色(黑 / 白),程序最后输出一条直线把所有黑点和白点分隔开 Sol 一个很直观的想法:首先询问\((dx, 0)\),然后 ...

  3. r.js压缩打包

    AMD模块化开发中的代码压缩打包工具——r.js 环境搭建基于nodejs:用于AMD模块化开发中的项目文件压缩打包,不是AMD模式也是可以的 javascript部分 压缩javascript项目开 ...

  4. Grunt压缩图片和JS

    今天我们来说一下用Grunt来压缩图片和JS吧! 首先要安装插件: 这是压缩图片的; npm install --save-dev gulp-imagemin 这是压缩JS的: npm install ...

  5. Java JSONArray的封装与解析

    package com.kigang.test; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import java.ut ...

  6. windows常用命令集锦

    开始→运行→输入的命令集锦 gpedit.msc-----组策略 sndrec32-------录音机 Nslookup-------IP地址侦测器 explorer-------打开资源管理器 lo ...

  7. 【转】成型滤波与匹配滤波的MATLAB实现

    转载自:https://blog.csdn.net/yuan1164345228/article/details/45919315 Fd=1; Fs=8; Delay=3; R=0.5; [yf,tf ...

  8. Windows装系统

    这几天电脑频繁崩溃,自己尝试着装了几次系统,遇到一些问题.有的解决了,有的没解决.将其一一记录在这里,作为经验参考. 自己以前最常用的方式是直接通过ultraiso将IOS文件解压到到U盘,会将U盘做 ...

  9. Nginx AWS ELB 域名解析后端502问题

    转载:http://liyangliang.me/posts/2016/04/nginx-aws-elb-name-resolution/

  10. oracle_How to Recover Data (Without a Backup!)

    How to Recover Data (Without a Backup!) It's the classic career-limiting maneuver(职业限制机动): accidenta ...