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 n, x0 и 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 xi, yi ( - 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:

 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std; ///咋看吓一跳,感觉暴力不科学啊,怎么可能知道一条直线上有
///多少点,所以就去计算每个点同炮的斜率,斜率一样,就在同
///同一条直线上。
const int MAX_SIZE = 1E4 + ; int main()
{
//freopen("in.txt", "r", stdin);
int n, i;
int x, y, px, py;
double kx, ky;
bool tag;
double k[MAX_SIZE]; while(scanf("%d %d %d", &n, &x, &y) != EOF)
{
tag = false;
int j = ;
for(i = ; i < n; i++)
{
scanf("%d %d", &px, &py);
kx = px - x;
ky = py - y;
if(kx == )
tag = true;
else
k[j++] = ky / kx;
} sort(k, k+j);
int ans = (tag == true) ? : ; for(i = ; i < j-; i++)
{
if(k[i] != k[i+])
{
ans++;
}
}
ans += (i == j-) ? : ;
cout << ans << endl;
}
return ;
} //题目需要注意的地方是,在中间计算过程,要用double去存储横纵坐标的差值。

CodeForces 514B的更多相关文章

  1. codeforces 514B. Han Solo and Lazer Gun 解题报告

    题目链接:http://codeforces.com/problemset/problem/514/B 题目意思:给出双头枪的位置(x0, y0),以及 n 个突击队成员的坐标.双头枪射击一次,可以把 ...

  2. 【codeforces 514B】Han Solo and Lazer Gun

    [题目链接]:http://codeforces.com/contest/514/problem/B [题意] 每次攻击可以把经过自己的一条直线上的所有点都毁掉; 然后给你n个目标物的坐标 问你最少要 ...

  3. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  4. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  5. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  6. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  7. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  8. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  9. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

随机推荐

  1. AE开发能否实现TOC Control里添加多个Data Frame

    问题: 在ArcMap中,菜单Insert下Data Frame,可以在TOC中增加Data Frame,在MapControl或者PageLayoutControl下都可以正常显示多个Data Fr ...

  2. centos 7.1 apache 源码编译安装

    Apache编译安装 一,需要软件: http://mirrors.cnnic.cn/apache//apr/apr-1.5.2.tar.gz 1.apr-1.5.2.tar.gz http://mi ...

  3. SourceTree推送时,增加额外的远程仓库,不用每次都自定义粘贴复制网络

    一.命令行添加 二.软件界面可以查看到结果 更新,以上是代码添加了远程仓库,最近,找到了不用代码,直接在文件夹里写地址来添加的方式.直接上图了.

  4. Centos6.5 Zabbix3 server端安装(一)

    一.准备阶段: 1.>关闭防火墙 /etc/init.d/iptables stop 2.>关闭selinux vim /etc/selinux/config SELINUX=disabl ...

  5. PHP代码编写规范

    一. 变量命名 a) 所有字母都使用小写 b) 首字母根据变量值类型指定 i. 整数i ii. 浮点数f iii. 字符串s iv. 布尔值b v. 数组a vi. 对象o vii. 资源r viii ...

  6. jQuery入门(2)使用jQuery操作元素的属性与样式

    jQuery入门(1)jQuery中万能的选择器 jQuery入门(2)使用jQuery操作元素的属性与样式 jQuery入门(3)事件与事件对象 jQuery入门(4)jQuery中的Ajax()应 ...

  7. PHP用curl伪造IP和来源

    以前没有这么搞过. 今天群里一个朋友在问这个问题. 查了下,CURL确实很强悍的可以伪造IP和来源. 1.php 请求 2.php . 1.php代码: $ch = curl_init(); curl ...

  8. Linux下提示 bash: xxx command not found

    今天在虚拟机上安装了CentOS5.5,发现运行一些很正常的诸如:init,shutdown,fdisk 等命令时,悍然提示: bash: xxx command not found. 那么,首先就要 ...

  9. 第3月第8天 RefCounted PlistBuddy

    1.RefCounted引用计数 class Frame : public RefCounted<Frame> { // ... } http://www.cnblogs.com/dsky ...

  10. 基于python的文件处理

    二.文件操作方法大全 1.os.mknod("test.txt") 创建空文件2.fp = open("test.txt",w) 直接打开一个文件,如果文件不存 ...