codeforces498A

sol:很显然答案就是两个坐标之间的线段数量

O(n)判断一下就行了

#include <bits/stdc++.h>
using namespace std;
typedef int ll;
inline ll read()
{
    ll s=0; bool f=0; char ch=' ';
    while(!isdigit(ch))    {f|=(ch=='-'); ch=getchar();}
    while(isdigit(ch)) {s=(s<<3)+(s<<1)+(ch^48); ch=getchar();}
    return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
    if(x<0) {putchar('-'); x=-x;}
    if(x<10) {putchar(x+'0'); return;}
    write(x/10); putchar((x%10)+'0');
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('
')
const double eps=1e-9;
ll n;
double nx1,ny1,nx2,ny2;
int main()
{
    ll i,wwx=0;
    double a,b,c;
    scanf("%lf%lf%lf%lf",&nx1,&ny1,&nx2,&ny2);
    n=read();
    for(i=1;i<=n;i++)
    {
        scanf("%lf%lf%lf",&a,&b,&c);
        if((nx1*a+ny1*b+c)*(nx2*a+ny2*b+c)<eps) wwx++; 
    }
    Wl(wwx);
    return 0;
}
View Code
河田は河田、赤木は赤木……。 私は誰ですか。教えてください、私は誰ですか。 そうだ、俺はあきらめない男、三井寿だ!
原文地址:https://www.cnblogs.com/gaojunonly1/p/15388284.html