【ZJU 1041 SSLGZ 1232】雷达覆盖

问题描述
以雷达心为圆心的半圆形雷达覆盖范围有多个点 雷达可旋转,求最多覆盖数(含在边界的)
样例输入
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
样例输出
3
4
4
算法描述
先过滤掉无法被雷达覆盖的点,之后枚举每一个点,与雷达坐标连接,利用叉积公式求出在这条线左边、右边及线上的点,取(左边+线上)和(右边+线上)两者的最大值。最后最大值即为答案。
叉积公式:m=(x1-x0)(y2-y0)-(x2-x0)(y1-y0)

const
  maxn=300;
var
  a:array[1..maxn,1..2] of longint;
  i,j,k,n,m,x,y,l,r,t,max:longint;
  rx,ry,rr:real;
begin
  readln(rx,ry,rr);
  while not(eof) do
    begin
      max:=0;
      m:=0;
      fillchar(a,sizeof(a),0);
      readln(n);
      for i:=1 to n do
        begin
          readln(x,y);
          if sqrt(sqr(rx-x)+sqr(ry-y))<=rr
            then begin
                   inc(m);
                   a[m,1]:=x;
                   a[m,2]:=y
                 end;
        end;
      for i:=1 to m do
        begin
          l:=0; r:=0; t:=0;
          for j:=1 to m do
            begin
              if (a[i,1]-rx)*(a[j,2]-ry)-(a[j,1]-rx)*(a[i,2]-ry)>0
                then inc(r);
              if (a[i,1]-rx)*(a[j,2]-ry)-(a[j,1]-rx)*(a[i,2]-ry)<0
                then inc(l);
              if (a[i,1]-rx)*(a[j,2]-ry)-(a[j,1]-rx)*(a[i,2]-ry)=0
                then inc(t)
            end;
          if l+t>max
            then max:=l+t;
          if r+t>max
            then max:=r+t;
        end;
      writeln(max);
      readln(rx,ry,rr);
    end;
end.

这里写图片描述
Pixiv ID:61784497

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值