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. python设计模式之单例模式(一)

    前言 单例模式是创建模式中比较常见和常用的模式,在程序执行的整个生命周期只存在一个实例对象. 系列文章 python设计模式之单例模式(一) python设计模式之常用创建模式总结(二) python ...

  2. MySQL Warning: Using a password on the command line interface can be insecure.解决办法

    转自 http://www.cnblogs.com/sunss/p/6256706.html  被一个小朋友问到,直接公布答案: If your MySQL client/server version ...

  3. juery给所有ID属性相同的div绑定一个事件

    案例: <div id="div1">内容</div> <div id="div1">内容</div> < ...

  4. PHP扩展插件 imagick 、PDO_MYSQL 安装

    环境准备 echo $LC_ALL echo "export LC_ALL=C" >> /etc/profile source /etc/profile yum ins ...

  5. 记点事! oracle 调用外部命令

    oracle执行系统命令   测试成功环境:windows XP+oracle 10g.window 2008 R2 + 11g   代码如下: www.2cto.com   Sql代码   crea ...

  6. csu 1769(数学)

    1769: 想打架吗?算我一个!所有人,都过来!(3) Time Limit: 2 Sec  Memory Limit: 128 MBSubmit: 262  Solved: 76[Submit][S ...

  7. nodeJs 常用模块(一)

    url url.parse() querystring querystring.parse( [string] , [分隔符] )  ,解析为js字面量 querystring.stringify() ...

  8. 【hdoj_2566】统计硬币(母函数?)

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=2566 本题可以借鉴母函数(组合数学)的思想. 题目可以这样理解:给一堆硬币,分别有1,2,5元的各无数个, ...

  9. MVC – 15.路由机制

    15.1.路由检测插件 - RouteDebug 15.2.路由约束 15.3.命名路由 15.4.验证码 15.5.ASP.NET MVC 与 三层架构 15.6.Area区域 15.6.1.尝试将 ...

  10. js获取url链接地址的参数

    访问地址为:http://XXX.com?style=green <script language="javascript"> var getArgs = functi ...