See car
Time Limit:2s Memory Limit:64MByte
Submissions:554Solved:207
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
记录有多少个不同的斜率就行了
<span style="font-size:18px;">#include<cstdio>
#include<iostream>
#define INF 0x3f3f3f3f
#include<algorithm>
using namespace std;
double k[110000];//代表直线的斜率
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
double a,b;
int n,i;
scanf("%lf%lf%d",&a,&b,&n);
for(i=0;i<=n;++i)//初始化
k[i]=INF;
int ans=0;
while(n--)
{
double x,y,temp;
scanf("%lf%lf",&x,&y);
if(x==a)
temp=0;
else
temp=(y-b)/(x-a);
k[ans++]=temp;
}
sort(k,k+ans);
int sum=unique(k,k+ans)-k;
printf("%d\n",sum);
}
return 0;
} </span>