雷達覆蓋(SSL_1232)


Time Limit:1000MS  Memory Limit:65536K
Total Submit:129 Accepted:57

Description

以雷達心爲圓心的半圓形雷達覆蓋範圍有多個點 雷達可旋轉,求最多覆蓋數(含在邊界的)

Input

Output

Sample Input

25 25 3.5------雷達座標與半徑
7----------點數
25 28-------點座標
23 27
27 27
24 23
26 23
24 29
26 29
350 200 2.0
5
350 202
350 199
350 198
348 200
352 200
995 995 10.0
4
1000 1000
999 998
990 992
1000 999
100 100 -2.5

Sample Output

3
4
4 
先用溝谷判斷點是否在雷達範圍內。................................................................................再用叉積:枚舉每一個在範圍內的點,與雷達連成直線,在用叉積判斷在直線的哪一邊。記錄下每一邊的點的個數,將大一邊的記錄進max,最後write出max即可

var
 map:array[0..1001,0..3]of longint;
 i,j,n,x,y,t,sum,max,xx,yy,left,right,mid:longint;
 l,s:real;
begin
 while true do
   begin
     read(x,y,l);
     if l<0 then break;
     read(n);
     for i:=1 to n do
       begin
         read(xx,yy);
         s:=sqrt(sqr(xx-x)+sqr(yy-y));
         if l>=s then
           begin
             inc(sum);
             map[sum,1]:=xx;
             map[sum,2]:=yy;
           end;
       end;

     for i:=1 to sum do
       begin
         for j:=1 to sum do
           begin
             if (map[i,1]-x)*(map[j,2]-y)-(map[j,1]-x)*(map[i,2]-y)=0 then inc(mid);
             if (map[i,1]-x)*(map[j,2]-y)-(map[j,1]-x)*(map[i,2]-y)>0 then inc(left);
             if (map[i,1]-x)*(map[j,2]-y)-(map[j,1]-x)*(map[i,2]-y)<0 then inc(right);
           end;
         if max<mid+left then max:=mid+left;
         if max<mid+right then max:=mid+right;
         mid:=0; right:=0; left:=0;
       end;
     fillchar(map,sizeof(map),0);
     l:=0; sum:=0;
     writeln(max);
     max:=0;
   end;
end.





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章