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. 记录webservice

    公司的一个老项目,定义了接口,供其他应用访问.定义的方式就是webservice. 我这边的环境是springboot. 首先引入依赖jar 声明一个服务端. @WebSerevice注解中name则 ...

  2. centos下java环境搭建安装

    1. 购买服务器(阿里云) 2. 重置密码,重启服务器 3. 创建账号work groupadd work #创建组 mkdir /data # 创建数据文件夹 useradd -d /data/wo ...

  3. PHP 垃圾回收机制详解

    前言:之前对PHP的GC只是了解了个大概,这次详细了解下PHP的垃圾回收机制(GC). 介于网上大部分都是PHP5.X的GC,虽然 php5 到 php7 GC部分做出的改动较小,但我觉得还是一起写下 ...

  4. WPF 高级篇 MVVM 附加属性

    原文:WPF 高级篇 MVVM 附加属性 WPF 特性之一 附加属性 在本文里实现文本框内容的验证 public class TextBoxHelper:DependencyObject { publ ...

  5. C#工具类MySqlHelper,基于MySql.Data.MySqlClient封装

    源码: using System; using System.Collections.Generic; using System.Linq; using System.Text; using Syst ...

  6. .net架构的浅谈

    ,net的架构有以下几种 1.两层架构:UI + 数据层 2.三层架构:UI + 业务层 + 数据层 3.三层 + 接口层 (把相关的业务层抽象成接口,下层来实现接口,中层是依赖) 4.三层 + 接口 ...

  7. C# Moq

    Moq 1 My Cases 1.1 简单入门 2 Reference 2.1 Methods 2.2 Matching Arguments 2.3 Properties 2.4 Events 2.5 ...

  8. Mark: 实现个toy版的脚手架(RPC)

    p.s.  这些小toy的规模都在几百~上千行代码量,但足以反映一个tool的核心思想. 包括: 一些中间件(消息队列.Netty) Spring的IoC容器:(自动依赖注入) —— 就是利用Java ...

  9. 机甲大师S1机器人编程学习,Windows 10 安装Scratch和简单实例学习

    机甲大师S1支持 Scratch 3.0以上版本. Scratch官方网址:https://scratch.mit.edu/  最新版本为3.4.0 今天在Windows 10上,安装最新版本. 1. ...

  10. JS基石之-----防抖节流函数

    防抖和节流函数   阅读目录 一 .防抖函数 二 .节流函数 三 .个人理解两者的区别   一.防抖函数 1.1 概念: 触发高频事件后n秒内函数只会执行一次,如果n秒内高频事件再次被触发,则重新计算 ...