codeforce 660D Number of Parallelograms
题意:询问多少个矩形。
统计横纵坐标差,放进vector中
#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<stack>
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int x[],y[];
vector<pair<int,int> >v;
int main(){
int n;
while(~scanf("%d",&n)){
for(int i=;i<n;i++)
scanf("%d%d",&x[i],&y[i]); for(int i=;i<n;i++){
for(int j=i+;j<n;j++){
//cout<<"~~"<<endl;
int dx=x[i]-x[j];
int dy=y[i]-y[j];
if(dx<||(dx==&&dy<)){
dx=-dx,dy=-dy;
}
v.push_back(make_pair(dx,dy));
}
}
//cout<<"~~"<<endl;
sort(v.begin(),v.end());
//printf("size:%d\n",v.size());
LL cnt=;
LL ans=;
for(int i=;i<(int)v.size()-;i++){
cnt++;
if(v[i+]!=v[i]){
ans+=cnt*(cnt-)/;
cnt=;
}
}
printf("%I64d\n", ans/);
}
return ;
}
codeforce 660D Number of Parallelograms的更多相关文章
- CodeForces 660D Number of Parallelograms
枚举两点,确定一条线段,计算每条线段的中点坐标. 按线段中点坐标排个序.找出每一种坐标有几个. 假设第x种坐标有y个,那么这些线段可以组成y*(y-1)/2种平行四边形. 累加即可. #include ...
- codeforces 660D D. Number of Parallelograms(计算几何)
题目链接: D. Number of Parallelograms time limit per test 4 seconds memory limit per test 256 megabytes ...
- 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】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 ...
- D. Number of Parallelograms 解析(幾何)
Codeforce 660 D. Number of Parallelograms 解析(幾何) 今天我們來看看CF660D 題目連結 題目 給你一些點,求有多少個平行四邊形. 前言 @copyrig ...
- 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 ...
- Educational Codeforces Round 11 D. Number of Parallelograms 暴力
D. Number of Parallelograms 题目连接: http://www.codeforces.com/contest/660/problem/D Description You ar ...
- CodeForces - 660D:Number of Parallelograms (问N个点多少个平行四边形)
pro:给定N个点,问多少个点组成了平行四边形.保证没有三点共线. sol:由于没有三点贡献,所以我们枚举对角线,对角线的中点重合的就是平行四边形.如果没说保证三点不共线就不能这么做,因为有可能4个点 ...
随机推荐
- 使用Github总结
1. 使用Git GUI 首先熟悉一下GUI,如下: 第一步,首先将代码fork到自己的版本库下面,如下: 并获取clone URL,如下图: 然后点击GUI克隆已有版本库,如下图: 点击克隆就可以得 ...
- 八,WPF 命令
WPF命令模型 ICommand接口 WPF命令模型的核心是System.Windows.Input.ICommand接口,该接口定义了命令的工作原理,它包含了两个方法和一个事件: public in ...
- 【mapping】 springmvc的注解mapping无法生效的问题
springmvc 始终无法加载 注解 map, 解决办法 八月 11, 2015 8:24:42 下午 org.springframework.web.servlet.DispatcherServl ...
- 开发设计模式(一)Command模式
Command定义 将来自客户端的请求传入一个对象,无需了解这个请求激活的 动作或有关接受这个请求的处理细节. 这是一种两台机器之间通讯联系性质的模式,类似传统过程语 言的 CallBack功能. 优 ...
- 一步步学习ASP.NET MVC3 (4)——Razor(2)
请注明转载地址:http://www.cnblogs.com/arhat 在上一章,我们介绍了Razor的一些基本语法,从Razor中我们可以出ASP.NET MVC的视图引擎给我们带来的便利,但是同 ...
- 数列 COGS1048:[Citric S2] 一道防AK好题
[题目描述] Czy手上有一个长度为n的数列,第i个数为xi. 他现在想知道,对于给定的a,b,c,他要找到一个i,使得a*(i+1)*xi2+(b+1)*i*xi+(c+i)=0成立. 如果有多个i ...
- objective-c常用数学方法
1. 三角函数 double sin (double);正弦 double cos (double);余弦 double tan (double);正切 2 .反三角函数 double as ...
- throw 与 throws的应用
throws---------->把异常交给调用处. 可以结合throw来同时使用. throws 用在方法声明处,表示本方法不处理异常.可以结合throw使用 throw 表示在方法中手工抛出 ...
- Access forbidden! XAMPP虚拟主机的问题
XAMPP Control Panel v3.2.1添加虚拟主机出现 Access forbidden! You don't have permission to access the request ...
- PYTHON多进程样码
敲了一晚上,留个念想. 发现它和LINUX的C编程差不多,就是作了PYTHON化的语法封装. 以后希望有机会能用上.. A,多进程函数化实现 import multiprocessing import ...