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个点多少个平行四边形)的更多相关文章

  1. CodeForces 660D Number of Parallelograms

    枚举两点,确定一条线段,计算每条线段的中点坐标. 按线段中点坐标排个序.找出每一种坐标有几个. 假设第x种坐标有y个,那么这些线段可以组成y*(y-1)/2种平行四边形. 累加即可. #include ...

  2. codeforce 660D Number of Parallelograms

    题意:询问多少个矩形. 统计横纵坐标差,放进vector中 #include<cstdio> #include<cstring> #include<iostream> ...

  3. Number of Parallelograms CodeForces - 660D (几何)

    Number of Parallelograms CodeForces - 660D You are given n points on a plane. All the points are dis ...

  4. codeforces 660D D. Number of Parallelograms(计算几何)

    题目链接: D. Number of Parallelograms time limit per test 4 seconds memory limit per test 256 megabytes ...

  5. 【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 ...

  6. Educational Codeforces Round 11 D. Number of Parallelograms 暴力

    D. Number of Parallelograms 题目连接: http://www.codeforces.com/contest/660/problem/D Description You ar ...

  7. Number of Parallelograms(求平行四边形个数)

    Number of Parallelograms time limit per test 4 seconds memory limit per test 256 megabytes input sta ...

  8. D. Number of Parallelograms

    D. Number of Parallelograms 原题链接 time limit per test 4 seconds memory limit per test 256 megabytes Y ...

  9. D. Number of Parallelograms 解析(幾何)

    Codeforce 660 D. Number of Parallelograms 解析(幾何) 今天我們來看看CF660D 題目連結 題目 給你一些點,求有多少個平行四邊形. 前言 @copyrig ...

随机推荐

  1. STAT UN2102 Homework

    STAT UN2102 Homework 4 [100 pts]Due 11:59pm Monday, May 6th on CanvasYour homework should be submitt ...

  2. 对比Python中_,__,xx__xx

      对比Python中_,__,xx__xx _ 的含义 不应该在类的外面访问,也不会被from M import * 导入. Python中不存在真正的私有方法.为了实现类似于c++中私有方法,可以 ...

  3. shell的交互式和非交互式登录

    工作中经常碰见环境变量加载问题,归根结底就是配置文件的加载问题. 一般会有四种模式:交互式登陆.非交互式登陆.交互式非登陆.非交互非登陆. 交互式和非交互式对环境变量的加载: +----------- ...

  4. Android创建自定义的布局和控件

    Android的自带布局有framelayout.linerlayout.relativelayout,外加两个百分比布局,但是这些无法灵活的满足我们的需要,所以我们要自己自定义并引入自己的布局.首先 ...

  5. CSS3 3D酷炫立方体变换动画

    我爱撸码,撸码使我感到快乐! 大家好,我是Counter,本章微博主要利用了CSS3的一些新特性, 主要用到关键帧来使3D图形运动起来,涉及到了一些抽象的思想,立体的想象. 先给大家看看完成的效果,代 ...

  6. POJ 1743 Musical Theme(后缀数组 + 二分)题解

    题意:一行数字,定义如下情况为好串: 1.连续一串数字,长度大于等于5 2.这行数字中多次出现这串数字的相似串,相似串为该串所有数字同加同减一个数字,如 1 2 3 和 5 6 7 3.至少有一个相似 ...

  7. oracle 根据出生日期计算年龄的年月日

    select years,months,abs( trunc( newer_date- add_months( older_date,years*12+months ) ) ) days from ( ...

  8. innoDB锁小结

    innodb的锁分两类:lock和latch. 其中latch主要是保证并发线程操作临界资源的正确性,要求时间非常短,所以没有死锁检测机制.latch包括mutex(互斥量)和rwlock(读写锁). ...

  9. vivado 创建PL工程

    参考来源 https://china.xilinx.com/video/hardware/i-and-o-planning-overview.html 前言 我Win10系统上的Xilinx Plat ...

  10. C# ToLookup

    下文参考翻译自: C#/.NET Little Wonders: The ToLookup() LINQ Extension Method 故事的背景 让我们先来创建一个简单的类来表示产品,产品有ID ...