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)\)

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

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

最新文章

  1. js验证电话号码的正则表达式
  2. java 20 - 4 IO流概述和一个简单例子解析
  3. ANDROID内存优化——大汇总(转)
  4. MAC 上升级python为最新版本
  5. C#中String类的几个方法(IndexOf、LastIndexOf、Substring)
  6. mysql 配置参数
  7. mysql-distinct去重、mysql-group …
  8. php composer使用
  9. 关于new Function使用以及将json格式字符串转化为json对象方法介绍
  10. java基础--动态代理实现与原理详细分析
  11. 51nod_1627:瞬间移动
  12. C++ Socket学习记录 -1
  13. Datatable转换为Json
  14. 【Visual C++】游戏编程学习笔记之四:透明动画实现
  15. javax.mail
  16. web.xml 设置字符编码
  17. Team Services的打包管理
  18. Manacher's Algorithm && 647. Palindromic Substrings 计算回文子串的算法
  19. 【CSS 技能提升】 :before和:after的使用
  20. go编译go-gtk,出现invalid flag in pkg-config --libs: -Wl,-luuid提示

热门文章

  1. python 根据文件的编码格式读取文件
  2. VS删除空白行
  3. WPF Adorner 弹出式工具栏 例子
  4. mongodb数据库环境配置
  5. 一、hexo+github搭建个人博客的过程记录
  6. 【题解】C2Crni - Crni [COCI2010] [SP7884]
  7. R数据挖掘 第三篇:聚类的评估(簇数确定和轮廓系数)和可视化
  8. 《 .NET并发编程实战》阅读指南 - 第4章
  9. Asp.NetCoreWebApi入门 - 从零开始新建api项目
  10. C# vb .NET读取识别条形码线性条码ISBN