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. 课堂笔记&总结与遇错纠错篇

    一.课堂笔记 二.个人总结 在学习和工作JDK是必不可少的程序员必备工具,遇到问题可以在帮助文档寻找答案! 接受能力不足,老师讲的知识点过去了,我经常还在想上一个知识点.希望老师有时候重点可以讲慢点哈 ...

  2. PAT 1055 The World's Richest

    #include <cstdio> #include <cstdlib> #include <cstring> #include <vector> #i ...

  3. 从list中随机选出几个数,并按照原来的顺序排列

    需求: 从list中随机选出几个数,并按照原来的顺序排列(比如从list中随机选出6个数) 方案一: //若对象size大于6,则随机去除6个对象,并按照原来的顺序排列 while(list.size ...

  4. Linux常用三十七条指令

    Linux常用三十七条指令 基础指令(11):ls,pwd,cd,mkdir,touch,cp.mv,rm,vim,>/>>/,cat 进阶指令(10):df,free,head,t ...

  5. javax.servlet.ServletException: java.lang.NoClassDefFoundError: javax/el/ELResolver错误解决办法

    今天不用eclipse.myeclipse等开发工具,纯手写JSP页面(有点作死)时突然出现以前从来没遇到过的问题,报错如下: HTTP Status 500 - java.lang.NoClassD ...

  6. js原形对象

    function clock(hour,minute,second){ this.constructor = clock ;//默认实现 /**/ } clock.prototype={ constr ...

  7. ant用法

    下载ant包,解压版,解压到某目录后配置环境变量即可,这里不在赘述.配置成功cmd ant-version,显示ant版本即OK.           ant是Apache的跨平台的构建工具,他可以实 ...

  8. SQL Server ->> Transparent Data Encryption(透明化数据加密)

    Comming later... 参考文献: Transparent Data Encryption (TDE)

  9. 3.GlusterFS 企业分布式存储的搭建

    3.1 硬件要求 一般选择 2U 机型,磁盘 SATA 盘 4TB,如果 IO 要求比较高,可以采购 SSD 固态硬盘.为了充分保证系统的稳定性和性能,要求所有 glusterfs 服务器硬件配置尽量 ...

  10. python入门21 pip安装、更新、卸载第三方包,验证包是否安装成功;pip自身更新升级

    1 安装第三方包 python3自带安装工具pip,且在安装时勾选添加path也会将pip.exe所在目录加入到环境变量(python安装目录\Scripts). 因此安装第三方软件特别简单,打开命令 ...