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 ...
随机推荐
- kubernetes endpoint一会消失一会出现的问题剖析
问题现象 发现某个service的后端endpoint一会显示有后端,一会显示没有.显示没有后端,意味着后端的address被判定为notready. endpoint不正常的时候: [root@lo ...
- 初始Vue
渐进式 JavaScript 框架 通过对框架的了解与运用程度,来决定其在整个项目中的应用范围,最终可以独立以框架方式完成整个web前端项目 走进Vue what -- 什么是Vue 可以独立完成前后 ...
- 4、zabbix基本配置入门
Zabbix监控流程: Host group --> Hosts(向server端添加被监控主机) --> Application(在agent定义) --> Items(在appl ...
- Spring-AOP环绕监听出错
Exception in thread "main" org.springframework.aop.AopInvocationException: Null return val ...
- CSS布局学习(三) - Normal Flow 正常布局流(官网直译)
默认情况下,元素是如何布局? 首先,取得元素的内容,加上内边距(padding),边框(border),外边距(margin)放在一个盒子中 - 这就是我们之前看到的盒子模型 默认情况下,块级元素的内 ...
- C# 说说lock到底锁谁?(2)
摘要 今天在园子里面有园友反馈关于[C#基础]说说lock到底锁谁?文章中lock(this)的问题.后来针对文章中的例子,仔细想了一下,确实不准确,才有了这篇文章的补充,已经对文章中的demo进行修 ...
- robot framework测试数据语法
Robot Framework通过文件的扩展名来选择使用何种解析器. 扩展名不分大小写. 可以识别的扩展名包括: HTML: .html, .htm 和 .xhtml TSV: .tsv 纯文本: . ...
- DAY15 模块
一.模块 1.1 模块的定义:模块就是一系列功能的集合体 1.2 模块的四种存在方式: 1.使用python编写的.py文件(任一py文件都可以作为模块) 2.包:一堆py文件的集合体 3.使用C编写 ...
- php 截取 小程序上传到服务器图片,
截取字符串传入数据库 $f_slide = htmlspecialchars_decode($_REQUEST['f_slide']); // echo "<pre>" ...
- 基于Python——实现两个文件夹中的文件拷贝
[背景]当复制一个文件夹中的某文件到另一个文件夹中时是一件很容易的事情,可是如果存在很多文件夹中的文件需要一一拷贝,就会变的很繁琐,稍有不慎就会遗漏,今天就用Python来解决这个问题—— [代码实现 ...