代码是转载的:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
double h1,r1,x1,y1,z1;
double h2,r2,x2,y2,z2,x3,y3,z3;
int T;
cin>>T;
while(T--){
scanf("%lf%lf%lf%lf%lf",&h1,&r1,&x1,&y1,&z1);
scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&h2,&r2,&x2,&y2,&z2,&x3,&y3,&z3);
double t1=h1+z1-r1;
double t2=0.9*h2+z2-r2;
double a=x1-x2,b=y1-y2,c=t1-t2;
double a1=b*z3-c*y3,b1=c*x3-a*z3,c1=a*y3-b*x3;
double dis=(a1*a1+b1*b1+c1*c1)/(x3*x3+y3*y3+z3*z3);
if(dis<=r1*r1&&a*x3+b*y3+c*z3>0) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}