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. Linux 脚本内容指定用户执行

    #!/bin/bash set -x ## 因为这些变量在下面要用,所以要写在最上面, ## 如果直接写在下面,则变量获取不到,并且下面的 $ 标识的都要用 引号引起来,否则这些参数接收不到 tarf ...

  2. pycharm设置字体大小

    pycharm 是很好的一个IDE,在windows下,和macOS下,都能很好的运行.唯一缺点是启动慢. 默认字体太小,在mac下,需要瞪大24K氪金狗眼才能看清. 为了保护好眼睛,我们需要把字体调 ...

  3. gradle-4.1-rc-1-all.zip gradle-4.1-rc-2-all.zip 免费下载(百度网盘)

    今天下载遇到官网不给力,给有需要的你 gradle-4.1-rc-1-all.zip 密码: uyey gradle-4.1-rc-2-all.zip 密码: txhh

  4. LeetCode312. Burst Balloons

    Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by ...

  5. 删除/添加/调用WordPress用户个人资料的联系信息

    如果你要折腾主题或者将WordPress站点开放注册,你可能需要自定义WordPress用户个人资料信息.下面倡萌将简单说一下如何删除.添加和调用自定义用户信息字段. 添加或删除字段,可以在主题的 f ...

  6. 使用jdk自带的工具native2ascii 转换Unicode字符和汉字

    1.控制台转换 1.1 将汉字转为Unicode: C:\Program Files\Java\jdk1.5.0_04\bin>native2ascii 测试 \u6d4b\u8bd5 1.2 ...

  7. WPF 获取指定文件的Icon

    C# var icon = System.Drawing.Icon.ExtractAssociatedIcon(@"filepath"); var m = new MemorySt ...

  8. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) F - Uniformly Branched Trees 无根树->有根树+dp

    F - Uniformly Branched Trees #include<bits/stdc++.h> #define LL long long #define fi first #de ...

  9. bzoj 1109

    思路:我们考虑dp[ i ] 表示的是 i 在指定位置上 的最大个数, dp[ i ] = max(dp[ j ] + 1) j需要满足3个条件 1. j < i 2. a[ j ] < ...

  10. CyclicBarrier 简介

    CyclicBarrier 简介 CyclicBarrier 的字面意思是可循环使用(Cyclic)的屏障(Barrier). 它要做的事情是,让一组线程到达一个屏障(也可以叫同步点)时被阻塞,直到最 ...