Codeforces886(Technocup2018) F Symmetric Projections

You are given a set of n points on the plane. A line containing the origin is called good, if projection of the given set to this line forms a symmetric multiset of points. Find the total number of good lines.

Multiset is a set where equal elements are allowed.

Multiset is called symmetric, if there is a point P on the plane such that the multiset is centrally symmetric in respect of point P.

Input

The first line contains a single integer \(n (1 ≤ n ≤ 2000)\) — the number of points in the set.

Each of the next n lines contains two integers \(x_i\) and \(y_i\) \(( - 10^6  ≤  x_i,  y_i  ≤  10^6)\) — the coordinates of the points. It is guaranteed that no two points coincide.

Output

If there are infinitely many good lines, print -1.

Otherwise, print single integer — the number of good lines.

Examples

input

3
1 2
2 1
3 3

output

3

input

2
4 3
1 2

output

-1

Note

Picture to the first sample test:

In the second sample, any line containing the origin is good.

题意描述

在平面上给出2000个点,求有多少条过原点的直线, 使这些点在直线上的投影对称

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

题解

(因为精度问题没过)

质心是所有点的平均坐标

???质心在合法的直线上的投影是对称重心???

假设两点是对称的, 那么他们的中点的投影必然是对称中心, 结合质心的性质, 这样可以唯一确定一条过原点的直线

注意到任意一点一定有投影后对称的点, 可能是自己, 所以只要随便拿一个点和\(n\)个点枚举就可以得到所有的可能直线, 即\(O(n)\)

判断直线可不可行有很多方式

需要基准点的题目可以把所有坐标改成相对坐标, 简化计算

Codeforces886(Technocup2018) F Symmetric Projections的更多相关文章

  1. CF886F Symmetric Projections

    题意:给你平面上n个点,问有多少条过原点的直线,使得这些点在该直线上的投影(做垂直,对应点)形成对称图形?n<=2000. 标程: #include<bits/stdc++.h> # ...

  2. Codeforces Round #445

    ACM ICPC 每个队伍必须是3个人 #include<stdio.h> #include<string.h> #include<stdlib.h> #inclu ...

  3. Mysql_以案例为基准之查询

    查询数据操作

  4. 1040. Longest Symmetric String (25)

    题目链接:http://www.patest.cn/contests/pat-a-practise/1040 题目: 1040. Longest Symmetric String (25) 时间限制 ...

  5. 牛客多校第四场 F Beautiful Garden

    链接:https://www.nowcoder.com/acm/contest/142/F来源:牛客网 题目描述 There's a beautiful garden whose size is n ...

  6. Fisheye projections from spherical maps [转]

    Fisheye projections from spherical maps Written by Paul Bourke May 2003, software updated January 20 ...

  7. Educational Codeforces Round 9 F. Magic Matrix 最小生成树

    F. Magic Matrix 题目连接: http://www.codeforces.com/contest/632/problem/F Description You're given a mat ...

  8. (第四场)F Beautiful Garden

    题目: F Beautiful Garden 题目描述 There's a beautiful garden whose size is n x m in Chiaki's house. The ga ...

  9. pat1040. Longest Symmetric String (25)

    1040. Longest Symmetric String (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, ...

随机推荐

  1. AspNet Core使用Mysql一些问题及解决方案

    本文假设的你的AspNet Core 2.2的Web程序通过EntityFrameworkCore连接使用MSSQL数据库,能正常使用. 如何想转为使用Mysql,其实不难. 1.安装Mysql这个简 ...

  2. VS2008激活找不到密匙输入框

    VS2008试用版到期后会无法使用,网上一搜就能找到很多激活码: Visual Studio 2008 Professional Edition: XMQ2Y-4T3V6-XJ48Y-D3K2V-6C ...

  3. Dos.ORM修改数据遇到的问题

    2019年11月6日,今天使用Dos.ORM进行数据的批量修改,出现修改一条数据造成所有数据相应状态改变的情况,代码如下: 按照一步步调试的方式,排查出原因:生成的orm实体类缺少 主键 的标识,该原 ...

  4. .NET 导入Excel服务器报未在本地计算机上注册 Microsoft.Jet.Oledb.4.0提供程序

    代码已经在本地运行正常,发布到服务器后,一直报未在本地计算机上注册 Microsoft.Jet.Oledb.4.0提供程序, 解决办法:读取EXCEL文件时最好使用ACE方式,jet对于高版本系统的服 ...

  5. layui 日期插件一闪而过

    关于一个layui插件日期的问题,在本地调试都是可以的,但发布到服务器上的时候,日期插件一闪而过,后来我以为是各个插件之间的冲突,我就每个插件的排除,但是还是无动于衷,然后我就去官网看了下是,需要加一 ...

  6. 【翻译】Tusdotnet中文文档(3)自定义功能和相关技术

    自定义功能和相关技术 本篇按照如下结构翻译 自定义功能 自定义数据仓库 相关技术 架构和总体概念 自定义数据仓库 tusdotnet附带一个存储库TusDiskStore,它将文件保存在磁盘上的一个目 ...

  7. Python - 注释 - 第四天

    注释 确保对模块, 函数, 方法和行内注释使用正确的风格 Python中的注释有单行注释和多行注释: Python中单行注释以 # 开头,例如: # 这是一个注释 print('Hello Pytho ...

  8. PIE SDK坐标转换算法

    1.算法功能简介 数据坐标转换是空间实体位置的位置描述,是从一种坐标系统变换到另一坐标系统的过程.通过建立两个坐标系之间一一对应关系来实现.是各种比例尺地图测量和编绘中建立地图数学基础必不可少的步骤. ...

  9. 纯C语言实现线性表

    #include <stdio.h> #include <stdlib.h> #define MAXSIZE 100 typedef int ElemType; typedef ...

  10. 浅谈Spring解决循环依赖的三种方式

    引言:循环依赖就是N个类中循环嵌套引用,如果在日常开发中我们用new 对象的方式发生这种循环依赖的话程序会在运行时一直循环调用,直至内存溢出报错.下面说一下Spring是如果解决循环依赖的. 第一种: ...