HDU 1174:http://acm.hdu.edu.cn/showproblem.php?pid=1174
The main idea: Chinese problem, very good understanding, make clear various variables on the line.
Train of thought: I know there seems to be two solutions, one is to seek the head of the bandits and bullets shot out of the line to find a straight distance, to judge the direction of the right; another is to find out the bullet point and the bandits head of the heart line, to find out the bullet shot straight lines, the two straight line of the angle, the bullet shot out point and bandits head of the heart connection, Find out the point of the bullet and the head of the bandits tangent, to find the angle between the two lines, compare the size of the two angles to determine whether it will hit.
Here I use the first method, put the first kind of bar.
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/
struct point {Double x, y, Z;}
A, B, C;
Compute cross product U x v point xmult (Point U,point v) {point ret;
Ret.x=u.y*v.z-v.y*u.z;
Ret.y=u.z*v.x-u.x*v.z;
ret.z=u.x*v.y-u.y*v.x;
return ret; ///two point distance, single parameter orientation size double Distance (points p1,point p2) {return sqrt ((p1.x-p2.x) * (p1.x-p2.x) + (P1.Y-P2.Y) * (P1.Y-P2.Y)
+ (P1.Z-P2.Z) * (P1.Z-P2.Z));
///vector Difference u-v point Subt (Point U,point v.) {POINT ret;
ret.x=u.x-v.x;
RET.Y=U.Y-V.Y;
Ret.z=u.z-v.z;
return ret;
///vector size Double vlen (point P) {return sqrt (p.x*p.x+p.y*p.y+p.z*p.z);}
Double Ptoline (Point p,point l1,point L2) {return Vlen (Xmult (SUBT), P,L1 (SUBT))) l2,l1 (/distance);}
int n;
Double h1,r1;
Double h2,r2,x3,y3,z3;
void Solve () {scanf ("%d", &n);
while (n--) {scanf ("%lf%lf%lf%lf%lf", &h1, &r1, &a.x, &A.Y, &A.Z); scanf ("%lf%lf%lf%lf%lf%lf%lf%lf", &h2, &r2, &b.x, &b.y, &b.z, &c.x, &C.Y, &C.Z);
A.Z = A.Z+H1-R1;
B.z = B.Z+H2*0.9-R2;
Double x = a.x-b.x;
Double y = a.y-b.y;
Double z = a.z-b.z;
printf ("%lf%lf%lf\n", X, Y, z);
Point D;
D.x = c.x+b.x;
D.y = C.Y+B.Y;
D.z = c.z+b.z;
Double d = ptoline (A, B, D);
printf ("%lf\n", D);
if (d <= R1 && (x*c.x+y*c.y+z*c.z > 0)) {printf ("yes\n");
else {printf ("no\n"); }} HDU 1174