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. IScroll Unable to preventDefault inside passive event listener due to target being treated as passive

    最近两天企业微信下IScroll突然无法滚动了,特别慢,之前好好的,发现主要是有红色的Unable to preventDefault inside passive event listener du ...

  2. Android Studio Analyze APK 一直显示 Parsing Manifest探因及解决

    一.背景 大家都知道,Android Studio开发工具自带了Analyze Apk,可以很方便的分析Apk文件.具体位于菜单build >> Analyze APK...路径下,点击后 ...

  3. flutter-初识(基础语法)

    前言:笔者学过 java,刚刚接触 flutter,记录下基本的一些语法. 一.认识Flutter Flutter 是 google 推出的,使用的 Dart 语言,它可以跨平台实现 Android ...

  4. WPF ResourceDictionary XAML资源 c#代码 获取与遍历

    使用C#代码来获取XAML资源,除去正常的FindResource.而且是能查询到资源的对象. 说实话还是很麻烦的. 比如说我现在有一堆静态资源放在xaml的资源中,我想通过绑定的方式来获取. 好比是 ...

  5. centos7安装pyenv

    一.安装pyenv: 1.>安装依赖包: yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel ...

  6. python动态视频下载器

    这里向大家分享一下python爬虫的一些应用,主要是用爬虫配合简单的GUI界面实现视频,音乐和小说的下载器.今天就先介绍如何实现一个动态视频下载器. 爬取电影天堂视频 首先介绍的是python爬取电影 ...

  7. Maven学习 一 (下载安装)

    Maven简介 Apache Maven 是一个软件项目管理工具.基于项目对象模型(project Object Model ,POM)的概念,Maven可用来管理项目的依赖,编译,文档等信息 使用M ...

  8. 线程池---Day26

    线程池思想概述 当我们要使用线程的时候就去创建一个线程时,虽然实现方便,但是会出现问题:如果并发的线程数量很多,并且每个线程都是执行一个时间很短的任务就结束了,这样频繁创建线程就会大大降低系统的效率, ...

  9. 分享几套2019年各大公司最新的PHP面试题,几斤几两一试便知

    从面试题发现不足,进而查漏补缺,比通过面试更难得 PHP面试题2019年奇虎360面试题和答案解析 PHP面试题2019年京东工程师面试题和答案解析 PHP面试题2019年新浪工程师面试题和答案解析 ...

  10. sql server 大数据, 统计分组查询,数据量比较大计算每秒钟执行数据执行次数

    -- 数据量比较大的情况,统计十分钟内每秒钟执行次数 ); -- 开始时间 ); -- 结束时间 declare @num int; -- 结束时间 set @begintime = '2019-08 ...