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. 绿色的宠物店cms后台管理系统模板——后台

    链接:http://pan.baidu.com/s/1c7qmsA 密码:2es8

  2. 设计模式之Proxy

    设计模式总共有23种模式这仅仅是为了一个目的:解耦+解耦+解耦...(高内聚低耦合满足开闭原则) 为什么要使用Proxy? 1.授权机制 不同级别的用户对同一对象拥有不同的访问权利. 2.某个客户端不 ...

  3. Linux下文件目录权限和对应命令的总结

    Linux下的权限有rwx三种,分别对应读,写,执行三种,在对文件和目录时,分别是下列含义: 对应权限的命令为: 文件: r-- cat, more, head, tail w-- echo, vi ...

  4. linux内核数据结构之链表【转】

    转自:http://www.cnblogs.com/Anker/p/3475643.html 1.前言 最近写代码需用到链表结构,正好公共库有关于链表的.第一眼看时,觉得有点新鲜,和我之前见到的链表结 ...

  5. 64_p6

    polkit-kde-5.10.1-1.fc26.x86_64.rpm 12-Jun-2017 13:45 84854 polkit-libs-0.113-8.fc26.i686.rpm 13-Apr ...

  6. juey点击tr选中里面的radio

    //点击一行选中银行卡 $("tr").bind("click",function(){ $("input:radio").attr(&qu ...

  7. 数据结构与算法之KMP 字符串匹配

    举例来说,有一个字符串"DSFFKFJD KFJLKFDLJFJ IWWJKJFJIA",我想知道,里面是否包含另一个字符串"JFJI",有的话就返回在原字符串 ...

  8. windows下phpstrom中xdebug的使用

    https://laravel-china.org/articles/16425/windows-phpstorm-xdebug-breakpoint-debugging

  9. UFLDL 教程学习笔记(六)主成分分析

    教程:http://ufldl.stanford.edu/tutorial/supervised/MultiLayerNeuralNetworks/ 以及这篇博文,写的很清楚:http://blog. ...

  10. 次短路经(dijsktra)

    #include <cstdio>#include <cstring>#include <queue>#include <algorithm>#defi ...