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. Scala 知识点掌握2

    Scala 基础知识点巩固2 1.集合中常用的函数 sum / max / min # 定义一个List[Int]val list1 = List(1,3,4,6,8,9)# 取集合中所有元素的和li ...

  2. Flask插件---flask_script与flask_migrate

    import app from flask_script import Manager from flask_migrate import Migrate,MigrateCommand my_app ...

  3. Android FlycoDialog 简单实用的自定义Android弹窗对话框之Dialog篇

    效果图镇楼   FlycoDialog是一款非常棒的弹窗对话框处理框架,今天在这里主要讲一下他的自定义弹出对话框的功能,这里以第二幅效果图为例,图片已经放在博客最下方,X号自己随便找一个东西代替吧.  ...

  4. Resharper安装及激活--转载

    原文地址:ReSharper2018破解详细方法   1.先安装好Resharper: 2.下载完补丁后解压,以管理员身份运行Patch.cmd,如下图所示,即破解成功: 3.打开VS,打开ReSha ...

  5. 学习spring mvc

    http://www.cnblogs.com/bigdataZJ/p/springmvc1.html

  6. js判断一个对象是否为数组

    1,真正的数组的判断方法 javascript中最简单的声明数组方法为: var a = []; 判断是否为数组的最直接的方法为: 复制代码 代码如下: a instanceof Array //tr ...

  7. Hadoop ->> MapReduce编程模型

    对于MapReduce模型的实现,有Java等一些语言实现了接口,或者用像Hive/Pig这样的平台来操作.MapReduce由Map函数.Reduce函数和Main函数实现.第一步,源数据文件按默认 ...

  8. win10下安装pytorch,torchvision

    电脑里以前安装了 tensorflow,现在因为学习需要,需要安装pytorch.还是在原来安装tensorflow的位置安装pytorch. 由于采用在线安装太慢了,而且中途还会因为网速不稳定终端! ...

  9. 学习笔记-java 集合

    背景: 看的是<java核心技术 第8版>,覆盖jdk1.6.主要是对集合全局和细节进行全面掌握,较深入的理解集合.本人对java比较熟悉,但是对于细节的理解不深,知识点还不全,这是知识的 ...

  10. 初次接触《C++程序设计原理与实践》一书

    前两天读书日,买了些书回来看.__Bjarne Stroustrup__的<C++程序设计原理与实践>便是其中一本.其实也没看完,只看了第0章-致读者,大师不愧是大师,只看了一章就让心生共 ...