zoukankan      html  css  js  c++  java
  • POJ3129计算几何水题

    大意:n个星星给出空间中坐标。m个望远镜在原点给出视野中心的一个点和视角pi。求有几个星星能被看到,n,m<=500.

    1A,直接用向量计算cos(0-星星,0-望远镜中心)>=pi即可。注意精度处理。

    program p3129;
    var
     x,y,z,x2,y2,z2,pi:array[0..501] of real;
     v:array[0..501] of boolean;
     n,m,i,j,ans:longint;
    
    Procedure fopen;
      begin
      assign(input,'p3129.in');
      assign(output,'p3129.out');
      reset(input);
      rewrite(output);
    end;
    
    Procedure fclose;
      begin
      close(input);
      close(output);
    end;
    
    Function l(px,py,pz:real):real;inline;
      begin
      exit(sqrt(sqr(px)+sqr(py)+sqr(pz)));
    end;
    
      begin
    
      while true do
        begin
        readln(n);
        if n=0 then break;
        for i:=1 to n do
          readln(x[i],y[i],z[i]);
        readln(m);
        for i:=1 to m do
          readln(x2[i],y2[i],z2[i],pi[i]);
        fillchar(v,sizeof(v),false);
        
        for i:=1 to n do
          for j:=1 to m do
            if (x[i]*x2[j]+y[i]*y2[j]+z[i]*z2[j])/l(x[i],y[i],z[i])/l(x2[j],y2[j],z2[j])-cos(pi[j])> -0.00000001 then
              begin
              v[i]:=true;
              break;
            end;
        ans:=0;
        for i:=1 to n do
          if v[i] then inc(ans);
        writeln(ans);
      end;
    
    end.
  • 相关阅读:
    HDU 5744
    HDU 5815
    POJ 1269
    HDU 5742
    HDU 4609
    fzu 1150 Farmer Bill's Problem
    fzu 1002 HangOver
    fzu 1001 Duplicate Pair
    fzu 1150 Farmer Bill's Problem
    fzu 1182 Argus 优先队列
  • 原文地址:https://www.cnblogs.com/htfy/p/2946766.html
Copyright © 2011-2022 走看看