CodeForces - 660D:Number of Parallelograms (问N个点多少个平行四边形)
pro:给定N个点,问多少个点组成了平行四边形。保证没有三点共线。
sol:由于没有三点共线,所以我们枚举对角线,对角线的中点重合的就是平行四边形。如果没说保证三点不共线就不能这么做,因为有可能4个点在一条直线上。
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
map<pair<int,int>,int>mp;
int x[],y[];
int main()
{
int N,ans=;
scanf("%d",&N);
rep(i,,N) scanf("%d%d",&x[i],&y[i]);
rep(i,,N)
rep(j,i+,N) {
ans+=mp[make_pair(x[i]+x[j],y[i]+y[j])];
mp[make_pair(x[i]+x[j],y[i]+y[j])]++;
}
printf("%d\n",ans);
return ;
}
CodeForces - 660D:Number of Parallelograms (问N个点多少个平行四边形)的更多相关文章
- CodeForces 660D Number of Parallelograms
枚举两点,确定一条线段,计算每条线段的中点坐标. 按线段中点坐标排个序.找出每一种坐标有几个. 假设第x种坐标有y个,那么这些线段可以组成y*(y-1)/2种平行四边形. 累加即可. #include ...
- codeforce 660D Number of Parallelograms
题意:询问多少个矩形. 统计横纵坐标差,放进vector中 #include<cstdio> #include<cstring> #include<iostream> ...
- Number of Parallelograms CodeForces - 660D (几何)
Number of Parallelograms CodeForces - 660D You are given n points on a plane. All the points are dis ...
- codeforces 660D D. Number of Parallelograms(计算几何)
题目链接: D. Number of Parallelograms time limit per test 4 seconds memory limit per test 256 megabytes ...
- 【CodeForces 660D】Number of Parallelograms(n个点所能组成的最多平行四边形数量)
You are given n points on a plane. All the points are distinct and no three of them lie on the same ...
- Educational Codeforces Round 11 D. Number of Parallelograms 暴力
D. Number of Parallelograms 题目连接: http://www.codeforces.com/contest/660/problem/D Description You ar ...
- Number of Parallelograms(求平行四边形个数)
Number of Parallelograms time limit per test 4 seconds memory limit per test 256 megabytes input sta ...
- D. Number of Parallelograms
D. Number of Parallelograms 原题链接 time limit per test 4 seconds memory limit per test 256 megabytes Y ...
- D. Number of Parallelograms 解析(幾何)
Codeforce 660 D. Number of Parallelograms 解析(幾何) 今天我們來看看CF660D 題目連結 題目 給你一些點,求有多少個平行四邊形. 前言 @copyrig ...
随机推荐
- 一.rest-framework之版本控制 二、Django缓存 三、跨域问题 四、drf分页器 五、响应器 六、url控制器
一.rest-framework之版本控制 1.作用 用于版本的控制 2.内置的版本控制 from rest_framework.versioning import QueryParameterVer ...
- 数据库分区分表(sql、mysql)
http://blog.csdn.net/lgb934/article/details/8662956 http://www.2cto.com/database/201503/380348.html ...
- 数据库只有mdf文件而没有ldf文件,如何恢复数据库
举例:数据库名为 TestData 第一步: 新建一个同名的数据库即TestData数据库 第二步: 停掉数据库服务,找到刚才新建的TestData数据库的mdf和ldf文件,删掉ldf文件,再用之前 ...
- Learning-Python【6】:Python数据类型(2)—— 列表、元组
一.列表类型 1.用途:记录多值,比如人的多个爱好 2.定义方式:在[ ]内用逗号分隔开多个任意类型的值 li = [1, 2, 3] 3.常用操作+内置方法 优先掌握的操作: 1)按索引存取值:可以 ...
- Learning-Python【27】:异常处理
一.错误与异常 程序中难免会出现错误,而错误分为两种 1.语法错误:这种错误,根本过不了 Python 解释器的语法检测,必须在程序执行前就改正 2.逻辑错误:比如用户输入的不合适等一系列错误 那什么 ...
- gets() 与 scanf() 的小尴尬
gets() 与 scanf() 函数相处呢有点小尴尬的,就是 gets() 在 scanf() 后边就爱捣乱.为什么呢,先了解它们两者之间的异同: 同: 都是可以接受连续的字符数据 并在字符结束后自 ...
- 随机森林和GBDT
1. 随机森林 Random Forest(随机森林)是Bagging的扩展变体,它在以决策树 为基学习器构建Bagging集成的基础上,进一步在决策树的训练过程中引入了随机特征选择,因此可以概括RF ...
- e1000e 网卡如遇到大包未线速问题解法
e1000e 网卡如遇到大包(>1280)未线速,把'DEFAULT_ITR'改为0, 不设中断频率上限试试 see@intel/e1000e/param.c/* Interrupt Throt ...
- CentOS6上ftp服务器搭建实战
1.安装程序包 [root@node1 ~]$ yum install -y vsftpd[root@node1 ~]$ yum install -y lftp # 安装测试软件 2.启动vsftpd ...
- DataSet select 的使用
1) Select()——获取所有 System.Data.DataRow 对象的数组. 2) Select(string filterExpression)——按照主键顺序(如果没有主键,则按照添加 ...