传送门:http://codeforces.com/contest/514/problem/B
B. Han Solo and Lazer Gun
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.

Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x0, y0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x0, y0).

Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers.

The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location.

Input

The first line contains three integers nx0 и y0 (1 ≤ n ≤ 1000,  - 104 ≤ x0, y0 ≤ 104) — the number of stormtroopers on the battle field and the coordinates of your gun.

Next n lines contain two integers each xiyi ( - 104 ≤ xi, yi ≤ 104) — the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point.

Output

Print a single integer — the minimum number of shots Han Solo needs to destroy all the stormtroopers.

Sample test(s)
input
4 0 0
1 1
2 2
2 0
-1 -1

output
2

input
2 1 2
1 1
1 0

output
1

Note

Explanation to the first and second samples from the statement, respectively

题目分析。。。eps别忘记了。。还有除0的特殊判断。。脑残了半天,除0没有判断出来

代码:

#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<set>
#include<map>
#include<vector>
#include<cstring>
#include<stack>
#include<cmath>
#include<queue>
#define INF 0x0f0f0f0f
#define eps 1e-10
using namespace std;
struct Point
{double x;double y;
};int main()
{int i,j,k,l,m,n,sum=1,flag=0;double x,y;double tana[1005];Point point[1005];scanf("%d%lf%lf",&n,&x,&y);for(i=0;i<n;i++){scanf("%lf%lf",&point[i].x,&point[i].y);}for(i=0;i<n;i++){if(fabs(point[i].x-x)>eps)tana[i]=(point[i].y-y)*1.0/(point[i].x-x);else{tana[i]=1000000000000;}}sort(tana,tana+n);for(i=1;i<n;i++){//printf("%.2lf ",tana[i]);if(tana[i]-tana[i-1]>eps)  sum++;}printf("%d\n",sum);}

Codeforces 514 B . Han Solo and Lazer Gun 精度 除0相关推荐

  1. CodeForces - 514B Han Solo and Lazer Gun

    题意: 给出N个点,和起始点X0,Y0,求N个点中有几组不同斜率与原点连接后斜率不同的点 思路: 考虑到可能出现的精度丢失,使用的分数的形式表示每个斜率,再用map去重就可以了 代码: #includ ...

  2. CF514B Han Solo and Lazer Gun

  3. Codeforces 514 D R2D2 and Droid Army(RMQ+二分法)

    An army of n droids is lined up in one row. Each droid is described by m integers a1, a2, ..., am, w ...

  4. Solo 博客系统 1.7.0 发布 - 新版 MD 编辑器

    本次发布主要是更新了 Markdown 编辑器,加入了全屏.Emoji 自动完成.粘贴时自动转换为 MD 格式的特性.(1.7.0 版本变更记录请看这里) 目前的 Markdown 编辑器有多好用呢? ...

  5. CodeForces - 1029B.Creating the Contest(最长上升子序列0(n)解法)

    思路:这道题无法用平时0(n^2)的解法来求最长上升子序列,会超时,只能用优化的最长上升子序列算法来求 You are given a problemset consisting of nn prob ...

  6. CodeForces Round #291 Div.2

    A. Chewbaсca and Number 感觉这道题巨坑,如果题中加粗标出来的输出得是正数算小坑的话.有个巨坑就是 the final number shouldn't start with a ...

  7. codeforces 514B

    题目: B. Han Solo and Lazer Gun time limit per test 1 second memory limit per test 256 megabytes input ...

  8. codeforces514

    514A. Chewbaсca and Number 大于4的就替换 开头特判 #include<cstdio> #include<cstring> #include<a ...

  9. Codeforces Gym 100463A Crossings 逆序数

    Crossings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100463 Description ...

最新文章

  1. 3月了,春天在夏天的后面来到了
  2. Nginx加入linux系统服务
  3. 【深度学习的数学】用神经网络进行图像分类时,为什么输出层的神经单元数量要跟分类数相同?可以采用二进制的表示方式么?
  4. 使用@Configuration注解来代替Spring的bean配置
  5. TCP协议——粘包与拆包
  6. 真香定律!一文带你搞懂Android多线程Handler,成功入职腾讯
  7. WINCE下I/O操作基础
  8. IGDB|2021年大学生夏令营开始报名啦!
  9. [转]Unity3D新手引导开发手记
  10. AutoMapper不用任何配置就可以从dynamic(动态)对象映射或映射到dynamic对象。
  11. 【渝粤教育】国家开放大学2018年秋季 7389-22T劳动与社会保障法 参考试题
  12. Keras指定GPU训练模式,设置GPU的使用量
  13. 海洋cms v6.53 v6.54版本漏洞复现
  14. ubuntu安装matlab2016b
  15. matlab 自定义直方图匹配_[转载]Matlab 直方图均衡化和直方图匹配
  16. 测试过程中印象最深刻的bug?| 万能回答必杀技
  17. MySQL容器部署及数据持久化(主从复制)
  18. 关于未来趋势的几点预测:
  19. 盘点国内6大抗DDOS攻击服务商
  20. lstm需要优化的参数_通过Keras 构建基于 LSTM 模型的故事生成器

热门文章

  1. 爱康集团私有化完成 张黎刚:今天是⼀个全新里程的开始
  2. 【三维几何学习】DiffusionNet: Discretization Agnostic Learning on Surfaces
  3. 初次接触java小感
  4. AlsaLib基本使用(基于1.2.4版本)
  5. Unity-网络开发(三)
  6. matlab计算特征多项式
  7. 生产用计算机软件管理台账,计算机台账管理系统
  8. 程序员你12点前睡觉了吗?
  9. REST API 最佳实践 – REST 端点设计示例
  10. 硕士发表SCI论文84篇遭质疑?!本人霸气回应:有无造假随便查!没有拼爹!...