Educational Codeforces Round 11 D. Number of Parallelograms 暴力
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 暴力的更多相关文章
- 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 ...
- Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process 题目连接: http://www.codeforces.com/contest/660/problem/C Description You are given an a ...
- Educational Codeforces Round 11 B. Seating On Bus 水题
B. Seating On Bus 题目连接: http://www.codeforces.com/contest/660/problem/B Description Consider 2n rows ...
- 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 ...
- 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 ...
- Educational Codeforces Round 11 C. Hard Process 前缀和+二分
题目链接: http://codeforces.com/contest/660/problem/C 题意: 将最多k个0变成1,使得连续的1的个数最大 题解: 二分连续的1的个数x.用前缀和判断区间[ ...
- Educational Codeforces Round 11
A. Co-prime Array http://codeforces.com/contest/660/problem/A 题意:给出一段序列,插进一些数,使新的数列两两成互质数,求插最少的个数,并输 ...
- Educational Codeforces Round 11 A
A. Co-prime Array time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- 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 ...
随机推荐
- makefile里PHONY的相关介绍
Phony Targets PHONY 目标并非实际的文件名:只是在显式请求时执行命令的名字.有两种理由需要使用PHONY 目标:避免和同名文件冲突,改善性能. 如果编写一个规则,并不产生目标文件 ...
- php pdo封装类
class MYPDO { protected static $_instance = null; protected $dbname = ''; protected $dsn; protected ...
- IDEA配置toString方法
1.toString JSON带父类toString public java.lang.String toString() { final java.lang.StringBuilder sb = n ...
- Django实现文章按年月归档、点赞和评论、发送邮件
文章归档的实现 我们在创建文章时,会在数据库中存储文章创建的时间这样的字段,一般用的都是datetime类型,记录文章创建的年月日和时分秒,所以我们直接使用文章的创建时间分类是无法实现文章的按年月归档 ...
- [目标检测]RCNN系列原理
1 RCNN 1.1 训练过程 (1) 训练时采用fine-tune方式: 先用Imagenet(1000类)训练,再用PASCAL VOC(21)类来fine-tune.使用这种方式训练能够提高8个 ...
- 关于语义化版本(semantic versioning or SemVer)
1 为什么要有SemVer? SemVer用来规范组件之间的依赖版本,它使用一个版本号来传递出组件的API的变化情况. 在理解这规范之后,看一眼依赖包的版本号,就知道API的变化(兼容性)程度,方便 ...
- Windows下 Tensorflow安装问题: Could not find a version that satisfies the requirement tensorflow
Tensorflow 需要 Python 3.5/3.6 64bit 版本: 具体的安装方式可查看:https://www.tensorflow.org/install/install_window ...
- [转]C/C++关于全局变量和局部变量初始化与不初始化的区别
原文链接:http://www.kingofcoders.com/viewNews.php?type=newsCpp&id=189&number=4836955386 在C语言里,全局 ...
- 火狐 firefox proxy moz=proxy:// 407错误 解决办法
设置代理后,访问任一网站均弹窗要求输入代理的用户名和密码,但是多次输入始终无法认证. 最后才发现原来firefox把代理服务器的认证信息当成网站的认证信息记录了. 解决方法:将已登录信息中的代理相关的 ...
- Codeforces Round #302 (Div. 1) C - Remembering Strings 状压dp
C - Remembering Strings 思路:最关键的一点是字符的个数比串的个数多. 然后就能状压啦. #include<bits/stdc++.h> #define LL lon ...