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. matplotlib中的基本概念

    有外语基础的朋友看这里: matplotlib官方文档 Figure(图像): 组成部分

  2. Struts2-学习笔记系列(10)-自定义类型转换

    注意name=user和对应action中的实例名称一致 这些代码是写在HTML文件中的 <s:form action="login"> <s:textfield ...

  3. Go语言的GPM调度器是什么?

    我是平也,这有一个专注Gopher技术成长的开源项目「go home」 导读 相信很多人都听说过Go语言天然支持高并发,原因是内部有协程(goroutine)加持,可以在一个进程中启动成千上万个协程. ...

  4. golang环境安装和配置

    go中环境安装 前言 最近在工作中需要新配置go环境,每次都要去网上查找教程,浪费时间,那么就自己总结下. 下载安装 linuxGolang官网下载地址:https://golang.org/dl/1 ...

  5. 数据结构和算法(Golang实现)(5)简单入门Golang-接口

    接口 在Golang世界中,有一种叫interface的东西,很是神奇. 一.数据类型 interface{} 如果你事前并不知道变量是哪种数据类型,不知道它是整数还是字符串,但是你还是想要使用它. ...

  6. 第一天 简单的python认证登陆代码

    #!/usr/bin/env python3# -*- coding:utf-8 -*-# name:zzyu welcome = '''-----------welcome to home----- ...

  7. 微信小程序与H5数据传递

    这的场景是 小程序webview 加载 H5应用 需求点: 1. 小程序的登录code 需要与H5应用的sessionId建立绑定关系 2.H5内发起微信小程序支付,支付参数传递到小程序,支付结果传递 ...

  8. Python队列的三种队列方法

    今天讲一下队列,用到一个python自带的库,queue 队列的三种方法有: 1.FIFO先入先出队列(Queue) 2.LIFO后入先出队列(LifoQueue) 3.优先级队列(PriorityQ ...

  9. SpringBoot事件监听机制源码分析(上) SpringBoot源码(九)

    SpringBoot中文注释项目Github地址: https://github.com/yuanmabiji/spring-boot-2.1.0.RELEASE 本篇接 SpringApplicat ...

  10. 1327C - Game with Chips (构造)

    题目大意:一个n*m的棋盘上有k个棋子,k个棋子相互关联,可以一起向上向下向左向右,当碰到边界时,如果继续移动会发生越界,那么该棋子会保持不动,其余棋子继续移动.问能否在2*n*m的移动次数内,使各个 ...