B. Han Solo and Lazer Gun

来源:互联网 发布:mac影音播放器 编辑:程序博客网 时间:2024/05/21 06:46

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 01 12 22 0-1 -1
output
2
input
2 1 21 11 0
output
1
Note

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


解题说明:此题是一道几何模拟题,判断点是否在一条直线上即可。

#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<string>#include<cmath>#include<cstdlib>using namespace std;int main(){    int x,y;    int s[1000][2];    int n;    int i,j,c=0;    int k[1000];    scanf("%d%d%d",&n,&x,&y);    for(i=0; i<n; i++,c++)    {        scanf("%d%d",&s[i][0],&s[i][1]);        for(j=0; j<i; j++)        {            if((s[i][0]-x)*(s[j][1]-y)==(s[i][1]-y)*(s[j][0]-x))            {                c--;                break;            }        }    }    printf("%d\n",c);    return 0;}



0 0
原创粉丝点击