吾不言
#include<cstdio> #include<cstdlib> #include<cmath> using namespace std; int n,m; double px[15],py[15],qx[15],qy[15]; inline int dcmp(double a,double b){ if (fabs(a-b)<=1e-6) return 0; if (a<b) return -1; return 1; } inline double Cross(double x1,double y1,double x2,double y2){ return x1*y2-x2*y1; } inline void calc(double x1,double y1,double x0,double y0,double &retx,double &rety){ retx=(x0*(x1*x0+y1*y0)+y0*(x0*y1-x1*y0))/(x0*x0+y0*y0); rety=(y0*(x1*x0+y1*y0)-x0*(x0*y1-x1*y0))/(x0*x0+y0*y0); } inline int dp(double x,double y,int t) { if (!t) { if (dcmp(x,100.0)<0 && dcmp(x,0.0)>0 && dcmp(y,100.0)<0 && dcmp(y,0.0)>0) return 1; return 0; } if (dcmp(Cross(x-px[t],y-py[t],qx[t]-px[t],qy[t]-py[t]),0.0)>=0) return 0; else { double retx,rety; calc(x-px[t],y-py[t],qx[t]-px[t],qy[t]-py[t],retx,rety); retx+=px[t]; rety+=py[t]; return dp(x,y,t-1)+dp(retx,rety,t-1); } } int main() { double _x,_y; freopen("t.in","r",stdin); freopen("t.out","w",stdout); scanf("%d",&n); for (int i=1;i<=n;i++) scanf("%lf%lf%lf%lf",px+i,py+i,qx+i,qy+i); scanf("%d",&m); for (int i=1;i<=m;i++) { scanf("%lf%lf",&_x,&_y); printf("%d\n",dp(_x,_y,n)); } return 0; }