水题,直接贴代码。
//poj 3129 //sep9 #include <iostream> #include <cmath> using namespace std; const double eps=0.00000001; struct P{ double x,y,z; }p[512],tel[64]; double a[64]; int main() { int i,j,cnt,n,m; while(scanf("%d",&n)==1&&n){ cnt=0; for(i=0;i<n;++i) scanf("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].z); scanf("%d",&m); for(i=0;i<m;++i) scanf("%lf%lf%lf%lf",&tel[i].x,&tel[i].y,&tel[i].z,&a[i]); for(i=0;i<n;++i){ int ok=0; for(j=0;j<m&&!ok;++j){ double ra=sqrt(p[i].x*p[i].x+p[i].y*p[i].y+p[i].z*p[i].z); double rb=sqrt(tel[j].x*tel[j].x+tel[j].y*tel[j].y+tel[j].z*tel[j].z); double c=acos((p[i].x*tel[j].x+p[i].y*tel[j].y+p[i].z*tel[j].z)/(ra*rb)); if(c<a[j]||fabs(c-a[j])<eps) ok=1; } if(ok) ++cnt; } printf("%d\n",cnt); } return 0; }
时间: 2024-10-19 15:00:57