Codeforces 499C:Crazy Town(计算几何)

时间:2023-03-09 08:09:31
Codeforces 499C:Crazy Town(计算几何)

题目链接

给出点A(x1,y1),B(x2,y2),和n条直线(ai,bi,ci,aix + biy + ci = 0),求A到B穿过多少条直线

枚举每条直线判断A、B是否在该直线两侧即可

#include<bits/stdc++.h>
using namespace std;
#define y1 asodifu

double x1,y1,x2,y2;
double a,b,c;
;

bool check()
{
    if((a*x1+b*y1+c)*(a*x2+b*y2+c)<eps) return true;
    return false;
}

int main()
{
    cin>>x1>>y1>>x2>>y2;
    int n;
    cin>>n;
    ;
    while(n--)
    {
        cin>>a>>b>>c;
        if(check()) ans++;
    }
    cout<<ans;
}