# 爆頭

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1744    Accepted Submission(s): 732

Problem Description
gameboy是一個CS高手，他最喜歡的就是扮演警察，手持M4爆土匪的頭。也許這裡有人沒玩過CS，有必要介紹一下“爆頭”這個術語：所謂爆頭，就是子彈直接命中對方的頭部，以秒殺敵人。

Input

Output

Sample Input
2
1.62 0.1 10.0 10.0 10.0
1.80 0.09 0.0 0.0 0.0 1.0 1.0 1.0
1.62 0.1 0.0 0.0 0.0
1.80 0.09 10.0 10.0 10.0 -1.0 -1.0 -1.0

Sample Output
YES
YES

Author
lwg

``````<span style="font-size:18px;">#include <iostream>
#include <cmath>
using namespace std;
//差乘公式：向量AB叉乘向量AC的模再除以向量AC的模就的到了B到AC的距離；
double chacheng(double x1,double y1,double z1,double x2,double y2,double z2)
{
double a, b, c;
a = y1*z2-z1*y2;
b = x1*z2-z1*x2;
c = x1*y2-y1*x2;
return sqrt((a*a b*b c*c))/sqrt((x2*x2 y2*y2 z2*z2));
}
int main()
{
int T;
double h1,r1,x1,y1,z1;
double h2,r2,x2,y2,z2,x3,y3,z3;
double a,b,c,dis;
cin>>T;
while (T--)
{
cin>>h1>>r1>>x1>>y1>>z1;
cin>>h2>>r2>>x2>>y2>>z2>>x3>>y3>>z3;    //(x3,y3,z3)代表方向向量
z1  = h1-r1;
z2  = h2*0.9-r2;
a = x1-x2;
b = y1-y2;
c = z1-z2;
dis = chacheng(a,b,c,x3,y3,z3);
if(dis<=r1 && (a*x3 b*y3 c*z3)>0)   //(a*x3 b*y3 c*z3)>0是為了判斷匪徒是不是在警察正面
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}</span>``````