Codeforces886(Technocup2018) F Symmetric Projections
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的更多相关文章
- CF886F Symmetric Projections
题意:给你平面上n个点,问有多少条过原点的直线,使得这些点在该直线上的投影(做垂直,对应点)形成对称图形?n<=2000. 标程: #include<bits/stdc++.h> # ...
- Codeforces Round #445
ACM ICPC 每个队伍必须是3个人 #include<stdio.h> #include<string.h> #include<stdlib.h> #inclu ...
- Mysql_以案例为基准之查询
查询数据操作
- 1040. Longest Symmetric String (25)
题目链接:http://www.patest.cn/contests/pat-a-practise/1040 题目: 1040. Longest Symmetric String (25) 时间限制 ...
- 牛客多校第四场 F Beautiful Garden
链接:https://www.nowcoder.com/acm/contest/142/F来源:牛客网 题目描述 There's a beautiful garden whose size is n ...
- Fisheye projections from spherical maps [转]
Fisheye projections from spherical maps Written by Paul Bourke May 2003, software updated January 20 ...
- Educational Codeforces Round 9 F. Magic Matrix 最小生成树
F. Magic Matrix 题目连接: http://www.codeforces.com/contest/632/problem/F Description You're given a mat ...
- (第四场)F Beautiful Garden
题目: F Beautiful Garden 题目描述 There's a beautiful garden whose size is n x m in Chiaki's house. The ga ...
- pat1040. Longest Symmetric String (25)
1040. Longest Symmetric String (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, ...
随机推荐
- 了解jsp,这一篇就够了.
jsp的执行过程: 1 客户端发出请求. 2 Web容器将JSP转译成Servlet源代码. 3 Web容器将产生的源代码进行编译. 4 Web容器加载编译后的代码并执行. 5 把执行结果响应至客户端 ...
- Deep Learning专栏--FFM+Recurrent Entity Network的端到端方案
很久没有写总结了,这篇博客仅作为最近的一些尝试内容,记录一些心得.FFM的优势是可以处理高维稀疏样本的特征组合,已经在无数的CTR预估比赛和工业界中广泛应用,此外,其也可以与Deep Networks ...
- https的原理入门
现在基本上互联网上访问的地址都是使用HTTPS协议了,只有局域网才会使用HTTP协议,因此了解HTTPS十分重要. HTTP存在的问题 上过网的朋友都知道,网络是非常不安全的.尤其是公共场所有很多免费 ...
- 不依赖Spring使用AspectJ达到AOP面向切面编程
网上大多数介绍AspectJ的文章都是和Spring容器混用的,但有时我们想自己写框架就需要抛开Spring造轮子,类似使用原生AspectJ达到面向切面编程.步骤很简单,只需要两步. 1.导入依赖 ...
- Mysql序列(七)—— order by优化
前言 在mysql中满足order by的处理方式有两种: 让索引满足排序,即扫描有序索引然后再找到对应的行结果,这样结果即是有序: 使用索引查询出结果或者扫描表得到结果然后使用filesort排序: ...
- 《 .NET并发编程实战》阅读指南 - 第12章
先发表生成URL以印在书里面.等书籍正式出版销售后会公开内容.
- 01 .NET CORE 2.2 使用OCELOT -- 简单使用
目前参考两篇文章,已实现基本的ocelot的网关功能. https://www.cnblogs.com/xlxr45/p/11320988.html https://www.jianshu.com/p ...
- LiveBOS Webservice初步使用
今天外部部门对接,需要我们这传输数据到他们的webservice,因为我是php的,他们java的demo没有参考意义,因此自己摸索着请求. 我使用的是php的扩展方法soap,首先new SoapC ...
- 初学Mybatis
首先配置mybatis配置文件 <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" &qu ...
- 设计模式之(十一)代理模式(Proxy)
软件开发行业有一个观点:任务问题都可以添加一个中间层来解决.代理模式也是这个思想下的产物. 首先看下代理模式的定义:为其他对象提供一种代理以控制对这个对象的访问.就是把类委托给另外一个类,用这个类来控 ...