# 解析：

### 思路：

1.三角形行列式面积公式。
2.投影。

``#include<iostream> #include<cstdio> #include<cctype> #include<cmath> #include<algorithm> using namespace std; #define ll long long #define re register #define gc getchar #define pc putchar #define cs const inline int getint(){ re int num; re char c; re bool f=0; while(!isdigit(c=gc()))f^=c=='-';num=c^48; while(isdigit(c=gc()))num=(num<<1)+(num<<3)+(c^48); return f?-num:num; } inline double getdb(){ re double x=0.0,y=1.0; re char c; re bool f=0; while(!isdigit(c=gc()))f^=c=='-';x=c^48; while(isdigit(c=gc()))x=(x*10)+(c^48); if(c!='.')return f?-x:x; while(isdigit(c=gc()))x+=(y/=10)*(c^48); return f?-x:x; } cs int N=5008; cs double eps=1e-6; struct Point{ double x,y; Point(double _x=0,double _y=0):x(_x),y(_y){} Point operator+(cs Point &b)cs{return Point(x+b.x,y+b.y);} Point operator-(cs Point &b)cs{return Point(x-b.x,y-b.y);} Point operator*(cs double &b)cs{return Point(x*b,y*b);} double operator*(cs Point &b)cs{return x*b.y-y*b.x;} double dot()cs{return x*x+y*y;} friend double dot(cs Point &a,cs Point &b){return a.x*b.x+a.y*b.y;} friend double cross(cs Point &a,cs Point &b){return a.x*b.y-a.y*b.x;} }O; inline double dist(cs Point &a){ return sqrt(a.dot()); } inline double dist(cs Point &a,cs Point &b){ return sqrt((a-b).dot()); } inline bool cmp(cs Point &a,cs Point &b){ return fabs(a.x-b.x)<eps?a.y<b.y:a.x<b.x; } struct Line{ Point p1,p2; Line(){} Line(Point _1,Point _2):p1(_1),p2(_2){} }line[N]; int n,ans[N],m; double x_1,y_1,x_2,y_2; signed main(){ while(n=getint(),n){ m=getint(); x_1=getint(); y_1=getint(); x_2=getint(); y_2=getint(); line[0].p1=Point(x_1,y_1); line[0].p2=Point(x_1,y_2); line[n+1].p1=Point(x_2,y_1); line[n+1].p2=Point(x_2,y_2); for(int re i=1;i<=n;++i){ x_1=getint(),x_2=getint(); line[i].p1=Point(x_1,y_1); line[i].p2=Point(x_2,y_2); } for(int re i=1;i<=m;++i){ Point c; c.x=getint(); c.y=getint(); int l=0,r=n; while(l<=r){ int mid=(l+r)>>1; if(cross(line[mid].p1-c,line[mid].p2-c)<0)r=mid-1; else l=mid+1; } ++ans[l-1]; } for(int re i=0;i<=n;++i)cout<<i<<": "<<ans[i]<<endl,ans[i]=0; cout<<endl; } return 0; } ``