http://poj.org/problem?id=2318
This is my first calculation of the geometry of the problem and then unexpectedly a A is super excited AH!!!
I just read the courseware on the cross-product and then thought to write like this I see Seniors code is too deep no, or write it yourself and then the wow haha
To give you a rectangular box and then give you an n-baffle to divide him into n+1 small area with m toys to give you the coordinates of the box and the coordinates of each bezel and the coordinates of each toy.
And ask you to ask how many toys in each small area are not very simple
Analysis:
What I'm thinking is, I'm going to show each baffle with a vector and give the coordinates of every toy to see if he's on the side of the bezel.
This is a two-point search. If the direct traversal is timed out, I think they're going to have to use two points.
The recursion of the two points seems to have been written so well for the first time
#include <iostream>#include<cstring>#include<algorithm>#include<queue>#include<cstdio>#include<cstdlib>#include<cctype>#include<math.h>#include<ctype.h>using namespacestd;#defineMemset (A, B) memset (A,b,sizeof (a))#defineN 5500typedefLong Longll;structnode{intx, Y, V;} P[n];intY2;intFind (intNxintNyintLintR) { if(l==r-1) returnl; intMid= (L+R)/2; Node D; D.x=nx-p[mid].v; D.y=ny-Y2; if((D.X*P[MID].Y)-(d.y*p[mid].x) >0)/// If D point is on the right {L=mid; R=R; returnFind (NX,NY,L,R); } Else if((D.X*P[MID].Y)-(d.y*p[mid].x) <0)/// If D point is on the left {L=l; R=mid; returnFind (NX,NY,L,R); } return 0;}intMain () {intN,m,x1,x2,y1,a[n]; while(SCANF ("%d",&N) {memset (A,0); intu,v; scanf ("%d %d%d%d%d",&m,&x1,&y1,&x2,&y2); p[0].x=X1; p[0].y=Y2; p[0].v=X1; for(intI=1; i<=n;i++) {scanf ("%d%d",&u,&v); p[i].x=u-v; P[i].y=y1-Y2; P[I].V=v; } p[n+1].x=x2; P[n+1].y=Y1; P[n+1].v=x2; for(intI=0; i<m;i++) {scanf ("%d%d",&u,&v); intAa=find (U,v,0, n+1); A[AA]++; } for(intI=0; i<=n;i++) {printf ("%d:%d\n", I,a[i]); } printf ("\ n"); } return 0;}
toys--poj2318