D. Number of Parallelograms

题目连接:

http://www.codeforces.com/contest/660/problem/D

Description

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

Sample Output

1

Hint

题意

平面给你n个点,问你能够组成多少个平行四边形

保证三点不共线,点都是不相同的

题解:

能够成平行四边形的两条边的东西,一定是两个相同的向量

那么我们n^2把所有向量都计算出来就好了,注意得人为的去规定一下方向什么的,然后就完了。

代码

#include<bits/stdc++.h>
using namespace std;
const int maxn = 2005;
map<pair<int,int>,int> H;
pair<int,int>P[maxn];
int main()
{
int n;scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d%d",&P[i].first,&P[i].second);
long long ans = 0;
for(int i=1;i<=n;i++)
{
for(int j=i+1;j<=n;j++)
{
pair<int,int> T;
T.first=P[i].first-P[j].first;
T.second=P[i].second-P[j].second;
if(T.first<0)T.first=-T.first,T.second=-T.second;
else if(T.second<0&&T.first==0)T.second=-T.second;
ans+=H[T];
H[T]++;
}
}
cout<<ans/2<<endl;
}

Educational Codeforces Round 11 D. Number of Parallelograms 暴力的更多相关文章

  1. Educational Codeforces Round 11 E. Different Subsets For All Tuples 动态规划

    E. Different Subsets For All Tuples 题目连接: http://www.codeforces.com/contest/660/problem/E Descriptio ...

  2. Educational Codeforces Round 11 C. Hard Process 二分

    C. Hard Process 题目连接: http://www.codeforces.com/contest/660/problem/C Description You are given an a ...

  3. Educational Codeforces Round 11 B. Seating On Bus 水题

    B. Seating On Bus 题目连接: http://www.codeforces.com/contest/660/problem/B Description Consider 2n rows ...

  4. Educational Codeforces Round 11 A. Co-prime Array 水题

    A. Co-prime Array 题目连接: http://www.codeforces.com/contest/660/problem/A Description You are given an ...

  5. Educational Codeforces Round 11 B

    Description Consider 2n rows of the seats in a bus. n rows of the seats on the left and n rows of th ...

  6. Educational Codeforces Round 11 C. Hard Process 前缀和+二分

    题目链接: http://codeforces.com/contest/660/problem/C 题意: 将最多k个0变成1,使得连续的1的个数最大 题解: 二分连续的1的个数x.用前缀和判断区间[ ...

  7. Educational Codeforces Round 11

    A. Co-prime Array http://codeforces.com/contest/660/problem/A 题意:给出一段序列,插进一些数,使新的数列两两成互质数,求插最少的个数,并输 ...

  8. Educational Codeforces Round 11 A

    A. Co-prime Array time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  9. Educational Codeforces Round 11——C. Hard Process(YY)

    C. Hard Process time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

随机推荐

  1. C++之C/C++内存对齐

    一.什么是字节对齐,为什么要对齐 现代计算机中内存空间都是按照byte划分的,从理论上讲似乎对任何类型的变量的访问可以从任何地址开始,但实际情况是在访问特定类型变量的时候经常在特 定的内存地址访问,这 ...

  2. centos7安装ssh服务

    1.查看是否安装了相关软件: rpm -qa|grep -E "openssh" 显示结果含有以下三个软件,则表示已经安装,否则需要安装缺失的软件 openssh-ldap-6.6 ...

  3. pip安装模块时:error: command 'gcc' failed with exit status 1

    用安装python模块出现error: command 'gcc' failed with exit status 1 问题: gcc编译缺少模块 解决方法: yum install gcc libf ...

  4. TreeSet基本用法

    TreeSet的基础方法: public class TreeSetTest { public static void main(String[] args) { TreeSet nums = new ...

  5. Effective C++笔记(三):资源管理

    参考:http://www.cnblogs.com/ronny/p/3745098.html 资源:动态分配的内存.文件描述器.互斥锁.图形界面中的字型与笔刷.数据库连接以及网络sockets等,   ...

  6. java并发编程实战笔记---(第五章)基础构建模块

    . 5.1同步容器类 1.同步容器类的问题 复合操作,加容器内置锁 2.迭代器与concurrentModificationException 迭代容器用iterator, 迭代过程中,如果有其他线程 ...

  7. 以太坊go-ethereum客户端(三)两种全节点启动模式

    这篇博客介绍一下go-ethereum全节点的两种启动模式:主网络快速启动和测试网络快速启动.这也是客户端所提供的两种启动方式,直接拿来使用即可.下面具体介绍一下使用方法. 主网络快速启动 其实,我们 ...

  8. Java String class methods

    Java String class methods 现在不推荐使用 StringTokenizer 类.建议使用 String 类的 split()方法或 regex(正则表达式). String c ...

  9. idea导入或者检出项目时发现编辑器左侧无法显示项目目录结构

    按下列步骤操作: 1. 关闭IDEA,  2.然后删除项目文件夹下的.idea文件夹 3.重新用IDEA工具打开项目

  10. PHP 5.4.0之Traits

    [PHP之Traits] As of PHP 5.4.0, PHP implements a method of code reuse called Traits. 1.Traits基础 2.优先级: ...