1052 - See car
Time Limit:2s Memory Limit:64MByte
Submissions:547Solved:203
DESCRIPTION
You are the god of cars, standing at (a, b) point.There are some cars at point (xi,yi)(xi,yi). If lots of cars and you are in one line, you can only see the car that is nearest to yourself. How many cars can you see?
It is guaranteed that xi>axi>a and yi>byi>b.
INPUT
There are multiple test cases.The first line is a number T (T
≤11 ≤11), which means the number of cases.For each case, first line has three integers
a,b,n(−109≤a,b≤109,0≤n≤105)a,b,n(−109≤a,b≤109,0≤n≤105).next
nn lines, each line contains two integer
(xi,yi)(−109≤xi,yi≤109)(xi,yi)(−109≤xi,yi≤109), which means the position of car.
OUTPUT
one line --- the number of car that you can see.
SAMPLE INPUT
20 0 31 1 2 23 30 0 41 12 22 34 6
SAMPLE OUTPUT
12
SOLUTION
通过斜率判断
#include<stdio.h>
#include<string.h>
#include<map>
#include<algorithm>
using namespace std;
map<double,int>mp;
int main()
{
int t,n,sum;
double a,b,x,y;
scanf("%d",&t);
while(t--)
{
sum=0;
scanf("%lf%lf%d",&a,&b,&n);
mp.clear();
while(n--)
{
scanf("%lf%lf",&x,&y);
if(mp[(y-b)/(x-a)]==0)
{
mp[(y-b)/(x-a)]=1;
sum++;
}
else
continue;
}
printf("%d\n",sum);
}
return 0;
}