#include
#include
using namespace std;
const int MAX = 105;
typedef struct node
{
double s, e;
}N;
N qu[MAX];
//double getX(int x1, int y1, int x, int y)//这个更简洁,不过我的也没错
//{
// if(x == x1)
// return (double)x;
// else
// {
// double ans = (double)(x1*y - x*y1) / (double)(y - y1);
// return ans;
// }
//}
bool cmp(N a, N b)
{
return a.s < b.s;
}
int main(void)
{
int cas;
scanf("%d", &cas);
while(cas--)
{
int n;
double x, y, x1, y1, x2, y2, u1, v1;
scanf("%d", &n);
scanf("%lf %lf", &x, &y);
for(int i = 0; i < n; i++)
{
scanf("%lf %lf %lf %lf", &x1, &y1, &u1, &v1);
double k, b;
double sx, ex;
if(x1 == x)
sx = x;
else
{
k = (y1 - y) / (x1 - x);
b = k * x - y;
sx = b / k;//第一个点的位置
}
if(u1 == x)
ex = x;
else
{
k = (v1 - y) / (u1 - x);
b = k * x - y;
ex = b / k;
}
if(sx <= ex)
{
qu[i].s = sx;
qu[i].e = ex;
}
else
{
qu[i].s = ex;
qu[i].e = sx;
}
}
if(n == 0)
{
printf("1\n");
continue;
}
sort(qu, qu+n, cmp);
int count = 1;
double max = qu[0].e;
for(int i = 1; i < n; i++)
{
if(qu[i].s > max)
{
count++;
}
if(qu[i].e > max)
max = qu[i].e;
}
printf("%d\n", count+1);
}
return 0;
}
相关文章: