You are given a point set with nn points on the 2D-plane, your task is to find the smallest number of points you need to add to the point set, so that all the points in the set are center symmetric.

All the points are center symmetric means that you can find a center point (X_c,Y_c)(Xc​,Yc​)(not necessarily in the point set), so that for every point (X_i,Y_i)(Xi​,Yi​) in the set, there exists a point (X_j,Y_j)(Xj​,Yj​) (ii can be equal to jj) in the set satisfying X_c=(X_i+X_j)/2Xc​=(Xi​+Xj​)/2 and Y_c=(Y_i+Y_j)/2Yc​=(Yi​+Yj​)/2.

Input

The first line contains an integer n(1 \le n \le 1000)n(1≤n≤1000).

The next nn lines contain nn pair of integers (X_i,Y_i)(Xi​,Yi​) (-10^6 \le X_i,Y_i \le 10^6)(−106≤Xi​,Yi​≤106) -- the points in the set

Output

Output a single integer -- the minimal number of points you need to add.

样例输入复制

3
2 0
-3 1
0 -2

样例输出复制

1

样例解释

For sample 11, add point (5,-3)(5,−3) into the set, the center point can be (1,-1)(1,−1) .

这个题,卡精度,如果除2之后,C++编译器抽风的出来的值不一样,存map就不准了,所以不除2,直接相加储存。

挺简单的。

#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<iostream>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
#define LL long long
#define MAXN 1100
#define esp 1e-2
map<pair<long long ,long long >,int>m;
int x[MAXN],y[MAXN];
int main()
{
double a,b;
int n,i,j,maxx=0;
scanf("%d",&n);
if(n==1||n==2) return cout<<0<<endl,0;
for(i=1; i<=n; i++)
scanf("%d%d",&x[i],&y[i]);
for(i=1; i<=n; i++)
for(j=i+1; j<=n; j++)
{
a=x[i]+x[j];
b=y[i]+y[j];
m[make_pair(a,b)]++;
maxx=max(maxx,m[make_pair(a,b)]);
}
int cnt=0;
for(auto po=m.begin(); po!=m.end(); po++)
{
if(po->second==maxx)
{
int a=po->first.first;
int b=po->first.second;
int w=0;
for(i=1; i<=n; i++)
{
if(a==2*x[i]&&b==2*y[i]) w++;
}
cnt=max(cnt,w);
}
}
printf("%d",n-2*maxx-cnt);
return 0;
}

签到题,以为很难,没做。

The Preliminary Contest for ICPC Asia Xuzhou 2019 徐州网络赛 K题 center的更多相关文章

  1. The Preliminary Contest for ICPC Asia Xuzhou 2019 徐州网络赛 XKC's basketball team

    XKC , the captain of the basketball team , is directing a train of nn team members. He makes all mem ...

  2. The Preliminary Contest for ICPC Asia Xuzhou 2019 徐州网络赛 D Carneginon

    Carneginon was a chic bard. But when he was young, he was frivolous and had joined many gangs. Recen ...

  3. The Preliminary Contest for ICPC Asia Xuzhou 2019 徐州网络赛 C Buy Watermelon

    The hot summer came so quickly that Xiaoming and Xiaohong decided to buy a big and sweet watermelon. ...

  4. The Preliminary Contest for ICPC Asia Xuzhou 2019 徐州网络赛 B so easy

    题目链接:https://nanti.jisuanke.com/t/41384 这题暴力能过,我用的是并查集的思想,这个题的数据是为暴力设置的,所以暴力挺快的,但是当他转移的点多了之后,我觉得还是我这 ...

  5. The Preliminary Contest for ICPC Asia Xuzhou 2019 徐州网络赛 A Who is better?

    A After Asgard was destroyed, tanker brought his soldiers to earth, and at the same time took on the ...

  6. 计蒜客 41391.query-二维偏序+树状数组(预处理出来满足情况的gcd) (The Preliminary Contest for ICPC Asia Xuzhou 2019 I.) 2019年徐州网络赛)

    query Given a permutation pp of length nn, you are asked to answer mm queries, each query can be rep ...

  7. The Preliminary Contest for ICPC Asia Xuzhou 2019 E XKC's basketball team [单调栈上二分]

    也许更好的阅读体验 \(\mathcal{Description}\) 给n个数,与一个数m,求\(a_i\)右边最后一个至少比\(a_i\)大\(m\)的数与这个数之间有多少个数 \(2\leq n ...

  8. The Preliminary Contest for ICPC Asia Xuzhou 2019

    A:Who is better? 题目链接:https://nanti.jisuanke.com/t/41383 题意: 类似于有N个石子,先手第一次不能拿完,每次后手只能拿 1 到 前一次拿的数量* ...

  9. The Preliminary Contest for ICPC Asia Xuzhou 2019 E. XKC's basketball team

    题目链接:https://nanti.jisuanke.com/t/41387 思路:我们需要从后往前维护一个递增的序列. 因为:我们要的是wi + m <= wj,j要取最大,即离i最远的那个 ...

随机推荐

  1. python socket简介

    一.socket是什么 socket是应用层与TCP/IP协议通信的中间软件抽象层,它是一组接口.在设计模式中,socket其实就是一个门面模式,它把复杂的TCP/IP协议隐藏在socket接口后面, ...

  2. spark下载安装,运行examples(spark一)

    1.官方网址 http://spark.apache.org/ image.png 2.点击下载 下载最新版本目前是(2.4.3)此spark预设为hadoop2.7或者更高版本,我前面安装的是had ...

  3. 【小学数学】算术口诀 独立音频MP3

    算术口诀 独立音频MP3 原文载于本人个人网站:http://www.unlimitedbladeworks.cc/writing_202004_01_sskj 特点 加法口诀 乘法口诀 独立音频 m ...

  4. redis 浅谈事务

    写在前面的话 之前在某个网站上看到一个问题:redis在什么情况下出现事务不会滚的情况,以此为由并结合redis官方文档整理这边笔记.不足之处,请指出,谢谢. 事务 redis支持事务,提供两条重要的 ...

  5. DES原理及代码实现

    一.DES基础知识DES技术特点 DES是一种用56位密钥来加密64位数据的方法    DES采取了分组加密算法:明文和密文为64位分组长度    DES采取了对称算法:加密和解密除密钥编排不同外,使 ...

  6. Jmeter发送jdbc请求进行大批量造数

    创建批量造数脚本,一个简单的结构如下图所示, 1.线程组(10个线程重复运行2次,相当于造20个数) 2.用户定义变量(这是全局变量,用于后面随机筛选用) 3.数据库连接配置 4.计数器(用于主键递增 ...

  7. 数据结构与算法--二分搜索(binary search)

    前言 之前面试准备秋招,重新翻起了<编程之美>.在第三章节看到了一道关于二分搜索的讨论,觉得有许多细节是自己之前也没怎么特别注意地方,比如二分搜索的初始条件,转化.终止条件之类的. 问题 ...

  8. Liunx常用操作(一)-删除命令

    在linux命令行模式下,如何一次性快速删除一行刚刚输入的命令? 经常在命令行输入命令的时候,一段文字都需要删除,一个字段一个字段,比较耗费时间 以下提供一些命令,配合在一起操作,可以一定程度提高工作 ...

  9. 使用openmp进行共享内存编程

    预处理指令pragma:在系统中加入预处理器指令一般是用来允许不是基本c语言规范部分的行为.不支持pragma的编译器会忽略pragma指令提示的那些语句,这样就允许使用pragma的程序在不支持它们 ...

  10. 米特运输——(dfs)

    米特是D星球上一种非常神秘的物质,蕴含着巨大的能量.在以米特为主要能源的D星上,这种米特能源的运输和储 存一直是一个大问题.D星上有N个城市,我们将其顺序编号为1到N,1号城市为首都.这N个城市由N- ...