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 ...
随机推荐
- HDU 5333 Undirected Graph(动态树)
题意 给定一棵 \(n\) 个节点, \(m\) 条边的无向图,每个点有点权,有 \(q\) 个询问,每次询问若删去存在一个节点权值在 \([L,R]\) 范围外的边,剩下的图构成了多少个连通块(询问 ...
- hduoj#1004 -Let the Balloon Rise [链表解法]
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 Problem Description Contest time again! How exci ...
- 扩展的GM命令
命令 说明 例子 .rl all 重载核心所有自定义数据表 .rl item 重载item_template .backup a 备份Auth数据库 .backup c 备份Charact ...
- CentOS7.4安装jdk1.8.0_201、Tomcat-8.5.38环境
有时候安装一些软件或者服务都需要jdk环境,今天就在centos1.4上安装最新的jdk环境. 检测历时安装 1.查看Linux自带的JDK是否已安装 # java -version 2.查看JDK信 ...
- rabbitmq channel参数详解
文章转载自: https://www.cnblogs.com/piaolingzxh/p/5448927.html 部分参数说明有修改 1.Channel 1.1 channel.exchang ...
- Yahoo Programming Contest 2019 F - Pass
F - Pass 思路: dp[i][j] 表示到第 i 个球为止放了 j 个蓝球的方案数 第 i 个球来自的位置的最右边是min(i, n) 转移方程看代码 代码: #pragma GCC opti ...
- vnpy官网说明文档网址
接触VNPY一年多,一直对作者设计原理和思想有所困惑.发一篇vnpy官网的说明文档,便于以后理解项目代码. http://www.vnpy.org/archives.html
- Lab 7-1
Analyze the malware found in the file Lab07-01.exe. Questions and Short Answers How does this progra ...
- 2019ExcelVBA一些自己掉进过的坑
1.公式手动重算问题 为避免代码执行过程中引发公式自动重算,拖慢运行速度,在代码中设置了公式手动重算,并计划在代码执行结束前恢复.如果在代码执行过程中捕获错误就直接退出,而没有执行到恢复公式自动重算, ...
- 接口文档模板(Markdown)
效果 目录 1. 查询指定项目属性接口 1. 查询指定项目属性 接口功能 获取制定项目的分类信息 URL http://www.api.com/index.php 支持格式 JSON HTTP请求方式 ...