标签:des style blog http color java os io
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1628 Accepted Submission(s): 678
1 #include<cstdio> 2 #include<cmath> 3 #include<cstring> 4 #include<stdlib.h> 5 #include<algorithm> 6 using namespace std; 7 int main() 8 { 9 int kase; 10 scanf("%d",&kase); 11 while(kase--) 12 { 13 double h1,r1,x1,y1,z1; 14 double h2,r2,x2,y2,z2; 15 double x3,y3,z3; 16 scanf("%lf %lf %lf %lf %lf",&h1,&r1,&x1,&y1,&z1); 17 scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&h2,&r2,&x2,&y2,&z2,&x3,&y3,&z3); 18 double mx,my,mz,na,nb,nc,dis; 19 20 mx=x1-x2; 21 my=y1-y2; 22 mz=(z1+h1-r1)-(z2+h2*0.9-r2);//m=(mx,my,mz)为警察与土匪两点头心的向量 23 24 na=my*z3-mz*y3; 25 nb=mz*x3-mx*z3; 26 nc=mx*y3-my*x3;//n=(nx,ny,nz)为m X (x3,y3,z3)和枪的方向向量的叉积 27 28 dis=sqrt((na*na+nb*nb+nc*nc)/(x3*x3+y3*y3+z3*z3));//dis为子弹头心的距离 29 if(dis<=r1&&(mx*x3+my*y3+mz*z3)>0)//这道给出的向量要求警察要在土匪面前 30 printf("YES\n"); 31 else 32 printf("NO\n"); 33 } 34 return 0; 35 }
HDU 1174 爆头 (计算几何),布布扣,bubuko.com
标签:des style blog http color java os io
原文地址:http://www.cnblogs.com/clliff/p/3899964.html