枚举两点,确定一条线段,计算每条线段的中点坐标。

按线段中点坐标排个序。找出每一种坐标有几个。

假设第x种坐标有y个,那么这些线段可以组成y*(y-1)/2种平行四边形。

累加即可。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std; const int maxn=+;
long long x[maxn],y[maxn];
int n;
struct X
{
long long a,b;
}s[maxn*maxn]; bool cmp(const X&a,const X&b)
{
if(a.a==b.a) return a.b<b.b;
return a.a<b.a;
} int main()
{
int n;
scanf("%d",&n);
for(int i=;i<=n;i++) scanf("%lld%lld",&x[i],&y[i]);
int cnt=;
for(int i=;i<=n;i++)
{
for(int j=i+;j<=n;j++)
{
s[cnt].a=x[i]+x[j];
s[cnt].b=y[i]+y[j];
cnt++;
}
}
sort(s,s+cnt,cmp);
long long num=;
long long ans=;
for(int i=;i<cnt;i++)
{
if(s[i].a==s[i-].a&&s[i].b==s[i-].b) num++;
else
{
ans=ans+num*(num-)/;
num=;
}
}
printf("%lld\n",ans);
return ;
}

CodeForces 660D Number of Parallelograms的更多相关文章

  1. codeforce 660D Number of Parallelograms

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

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

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

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

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

  4. 【CodeForces 660D】Number of Parallelograms(n个点所能组成的最多平行四边形数量)

    You are given n points on a plane. All the points are distinct and no three of them lie on the same ...

  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. CodeForces - 660D:Number of Parallelograms (问N个点多少个平行四边形)

    pro:给定N个点,问多少个点组成了平行四边形.保证没有三点共线. sol:由于没有三点贡献,所以我们枚举对角线,对角线的中点重合的就是平行四边形.如果没说保证三点不共线就不能这么做,因为有可能4个点 ...

随机推荐

  1. codeforces 689B Mike and Shortcuts 最短路

    题目大意:给出n个点,两点间的常规路为双向路,路长为两点之间的差的绝对值,第二行为捷径,捷径为单向路(第i个点到ai点),距离为1.问1到各个点之间的最短距离. 题目思路:SPFA求最短路 #incl ...

  2. runtime关联属性示例

    前言 在开发中经常需要给已有的类添加方法和属性,但是Objective-C是不允许给已有类通过分类添加属性的,因为类分类是不会自动生成成员变量的.但是,我们可以通过运行时机制就可以做到了. 本篇文章适 ...

  3. php杂乱

    //    //    if ( $_GET['action'] == 'search' ) {//        $_clean = array();//        $_clean['stype ...

  4. Struts2 请求数据的自动封装 及 自定义转换器类

    请求数据自动封装: 实现原理:使用了参数拦截器.struts-default.xml中 <interceptor name="params" class="com. ...

  5. sqlserver2008行锁

    select * from tablename WITH (UPDLOCK) where Id=#value#

  6. Android简单逐帧动画Frame的实现(二)

    Android简单逐帧动画Frame的实现   Android简单逐帧动画Frame的实现 1.逐帧动画 即是通过播放预先排序好的图片来实现动态的画面,感觉像是放电影. 2.实现步骤: 1. 在工程里 ...

  7. java数组的引用

    数组属于应用型变量,因此两个相投类型的数组如果具有相同的引用,它们就有完全相同的元素 如: int a[]={1,2,3},b[]={4,5} 如果a=b;则a[]={4,5} public clas ...

  8. php 创建删除数据库

    <?php $dbhost = 'localhost:3306'; $dbuser = 'root'; $dbpass = ''; $conn = mysql_connect($dbhost, ...

  9. Linux一些命令

    1.查看系统安装软件 rpm -qa  //(不包括绿色安装的软件程序,也就是直接在安装目录中启动的不包括) rpm -qa |grep gcc 参数解释:q ——询问 a —— 查询全部   l — ...

  10. Android多线程下安全访问数据库

    http://zhiwei.neatooo.com/blog/detail?blog=5343818a9d4869f0310000de github 原文https://github.com/dmyt ...