___________________________________________________
题目大意:一个箱子用木板分成几个区间,给一些玩具的坐标,求各个区间有几个玩具。
对于每一个玩具,因为输入的区间是有序的,所以采用二分木板,判断一个玩具在哪个区间。
___________________________________________________
1 Program Stone; 2 var i,n,m,x1,x2,y1,y2,xi,yi:longint; 3 ui,li:array[0..10000]of longint; 4 ans:array[0..10000]of longint; 5 procedure init; 6 var i,j,k:longint; 7 begin 8 readln(n,m,x1,y1,x2,y2); 9 ui[0]:=x1;li[0]:=x1;10 ui[n+1]:=x2;li[n+1]:=x2;11 if n=0 then halt;12 for i:=1 to n do readln(ui[i],li[i]);13 end;14 Function cross(x1,y1,x2,y2,x3,y3,x4,y4:longint):longint; //叉积15 begin16 cross:=(x2-x1)*(y4-y3)-(y2-y1)*(x4-x3);17 end;18 function ef(x,y:longint):longint;19 var i,j,k,left,right,mid:longint;20 begin21 left:=0;right:=n+1;22 while left+10 then right:=mid;28 end;29 ef:=left;30 end;31 Procedure print;32 var i:longint;33 begin34 for i:=0 to n do35 writeln(i,': ',ans[i]);36 writeln;37 fillchar(ans,sizeof(ans),0);38 end;39 Begin40 assign(input,'input.in');reset(input);41 while true do42 begin43 init;44 for i:=1 to m do45 begin46 readln(xi,yi);47 inc(ans[ef(xi,yi)]);48 end;49 print;50 end;51 end.52 53