题目:

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.

Examples
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:

分析:

数据结构里面找到的题...然而并没想到数据结构解法?...

判有多少种不同的斜率 考虑到浮点数带来的误差,可用最简分数来描述斜率

代码:

#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;set<P> s;int gcd(int a,int b){
//  if(b>a) swap(a,b);//交换的话负数会出问题 if(b==0) return a;else return gcd(b,a%b);
}int main(){ios_base::sync_with_stdio(false);int n,x,y;int a,b,ans=0;s.clear();cin>>n>>x>>y;while(n--){cin>>a>>b;a-=x,b-=y;int mod=gcd(a,b);a/=mod;b/=mod;P p=P(a,b);
//      cout<<p.first<<"  "<<p.second<<endl;if(!s.count(p)) ans++,s.insert(p);}cout<<ans<<endl;return 0;
}

codeforces 514B相关推荐

  1. F - 恐怖分子 CodeForces - 514B

    F - 恐怖分子 CodeForces - 514B 有n个恐怖分子在站在一个平面上,每个恐怖分子都有一个位置坐标位置(x,y).现在有一个激光武器要用来消灭这些恐怖分子,这个武器所在的位置是(x0, ...

  2. CodeForces - 514B Han Solo and Lazer Gun

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

  3. CodeForces 514B - Watto and Mechanism

    这题看网上题解,都是相除然后什么暴力的,感觉没有必要.实际上就是计算每个点相当于炮塔的斜率,考虑到斜率是浮点数,因此可以把分数约分,然后比较有多少个这样不同的最简分数即可.刚开始用数组开的比较大内存超 ...

  4. CodeForces 375D Tree and Queries

    传送门:https://codeforces.com/problemset/problem/375/D 题意: 给你一颗有根树,树上每个节点都有其对应的颜色,有m次询问,每次问你以点v为父节点的子树内 ...

  5. 「日常训练」Bad Luck Island(Codeforces Round 301 Div.2 D)

    题意与分析(CodeForces 540D) 是一道概率dp题. 不过我没把它当dp做... 我就是凭着概率的直觉写的,还好这题不算难. 这题的重点在于考虑概率:他们喜相逢的概率是多少?考虑超几何分布 ...

  6. 【codeforces 812C】Sagheer and Nubian Market

    [题目链接]:http://codeforces.com/contest/812/problem/C [题意] 给你n个物品; 你可以选购k个物品;则 每个物品有一个基础价值; 然后还有一个附加价值; ...

  7. CodeForces 获得数据

    针对程序的输出可以看见 CodeForces :当输入.输出超过一定字符,会隐藏内容 所以:分若干个程序进行输入数据的获取 1. 1 for (i=1;i<=q;i++) 2 { 3 scanf ...

  8. codeforces水题100道 第二十七题 Codeforces Round #172 (Div. 2) A. Word Capitalization (strings)...

    题目链接:http://www.codeforces.com/problemset/problem/281/A 题意:将一个英文字母的首字母变成大写,然后输出. C++代码: #include < ...

  9. CodeForces 595A

    题目链接: http://codeforces.com/problemset/problem/595/A 题意: 一栋楼,有n层,每层有m户,每户有2个窗户,问这栋楼还有多少户没有睡觉(只要一个窗户灯 ...

最新文章

  1. s-seq 生成序列化数字
  2. Mybait缓存机制
  3. 我用Python破解了同事的加密压缩包
  4. 500w 的引用类型和值类型到底有多大差异?
  5. python函数可以作为容器对象吗_正确理解Python函数是第一类对象
  6. Java中dao层、service层、controller层、entity层和view层的概述
  7. 快用苹果助手安装失败_穿越火线辅助腾讯手游助手常见问题汇总
  8. 使用liteide开发go问题收集
  9. 做微商不推广,也能赚钱?
  10. 计算机维护费入什么会计科目,金税盘技术维护费计入什么科目_增值税
  11. 微信小程序—使用阿里巴巴iconfont矢量图标素材
  12. fat32文件系统格式在linux,FAT32文件系统的存储组织结构(一)
  13. 以太坊 day (6) 简单众筹项目的演示
  14. Cocos2d-js cc.director介绍
  15. 51cto python数据分析系列课程 55g_热图_ Python数据分析系列视频课程--玩转数据可视化_数据可视化视频-51CTO学院...
  16. 目标检测——小目标检测问题
  17. java实现24点经典游戏
  18. IndexedDB踩坑必须注意点!!!
  19. MRCTF 2020-“TiKi小组”
  20. 自律自学,越努力越幸运

热门文章

  1. 编程语言只是一个工具
  2. Spire.XLS for Java 12.11.8 Crack
  3. QQ升到9个太阳需要58年左右时间!
  4. TS战队拿下冠军,微博拿下TS战队
  5. Node.js知识点整理之----Buffer类
  6. 【牛客网华为机试】HJ89 24点运算
  7. UVA 1471 Defense Lines (LIS变形)
  8. 阿里四面之后才懂得如何更好的学Java
  9. linux忘记root密码VMware-centos6.8演示
  10. 以梦为码,不负韶华。