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. Bugku-CTF之域名解析(听说把 flag.baidu.com 解析到123.206.87.240 就能拿到flag)

    Day 7 域名解析 50 听说把 flag.baidu.com 解析到123.206.87.240 就能拿到flag    

  2. 剑指offer(2)替换空格

    题目描述 请实现一个函数,将一个字符串中的空格替换成“%20”.例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy. 题目分析 我们如果要替换空格,两步 ...

  3. 剑指offer(23)二叉搜索树的后序遍历序列

    题目描述 输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历的结果.如果是则输出Yes,否则输出No.假设输入的数组的任意两个数字都互不相同. 题目分析 1.后续遍历我们可以知道,最右边的是根节 ...

  4. 2018.9.22 NOIP模拟赛

    *注意:这套题目应版权方要求,不得公示题面. 从这里开始 Problem A 妹子 Problem B 旅程 Problem C 老大 因为业务水平下滑太严重,去和高一考NOIP模拟,sad... P ...

  5. Codeforces 939C - Convenient For Everybody

    2018-03-03 http://codeforces.com/problemset/problem/939/C C. Convenient For Everybody time limit per ...

  6. Java Volatile关键字 以及long,double在多线程中的应用

    概念: volatile关键字,官方解释:volatile可以保证可见性.顺序性.一致性. 可见性:volatile修饰的对象在加载时会告知JVM,对象在CPU的缓存上对多个线程是同时可见的. 顺序性 ...

  7. Bytom信息上链教程

    比原项目仓库: Github地址:https://github.com/Bytom/bytom Gitee地址:https://gitee.com/BytomBlockchain/bytom 用比原链 ...

  8. mac git 删除本地仓库文件

    递归清除本地文件夹下的Git文件,如果想重新建立仓库,那么在重新初始化新建的git仓库 //删除文件夹下的所有 .git 文件 find . -name ".git" | xarg ...

  9. Qt基础学习---滑动条之QSlider

    Qt滑动条基本用法: //mydialog.h #ifndef MYDIALOG_H #define MYDIALOG_H #include <QDialog> class QLineEd ...

  10. centos install jdk

    =========== 查询jdk版本 ===========yum search jdk =========== 安装jdk 64位开发版 ===========yum -y install jav ...