题目是中文的,就不再赘述了。其实方法比题意还简单。
设警头心为O1,匪头心O2,警头心到匪头切点为D,枪方向向量为O1B;
只要∠BO1O2 <= ∠O2O1D 就能爆头。。。。
可能是后台比较水吧,对精度什么要求不太高。。
总之又是一道水题。。。
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <cmath>
#include <algorithm>
using namespace std;
struct N
{
double x,y,z,h,r;
}t,p;
struct V
{
double x,y,z;
}v1,v2,v3;
double callen(V v)
{
return sqrt(v.x*v.x + v.y*v.y + v.z*v.z);
}
double calcos(V v1,V v2)
{
return (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z)/( sqrt(v1.x*v1.x + v1.y*v1.y + v1.z*v1.z)*sqrt(v2.x*v2.x + v2.y*v2.y + v2.z*v2.z) );
}
int main()
{
int T;
double a1,a2,l1;
scanf("%d",&T);
while(T--)
{
scanf("%lf %lf %lf %lf %lf",&t.h,&t.r,&t.x,&t.y,&t.z);
scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&p.h,&p.r,&p.x,&p.y,&p.z,&v1.x,&v1.y,&v1.z);
p.h *= 0.9;
p.z += p.h - p.r;
t.z += t.h - t.r;
v2.x = (t.x - p.x);
v2.y = (t.y - p.y);
v2.z = (t.z - p.z);
l1 = callen(v2);
a1 = t.r/l1;
a1 = asin(a1);
a2 = acos(calcos(v1,v2));
if(a2 > a1)
cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return 0;
}