提交时间:2022-10-15 11:27:53
运行 ID: 60358
#include<iostream> #include<cstdio> #include<cmath> using namespace std; int main(){ int t; cin>>t; while(t--){ double x1,y1,x2,y2,x3,y3,r; cin>>x1>>y1>>x2>>y2>>x3>>y3>>r; if(x1==x2){ double t=abs(x3-x1)-r; double t2=max(sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1)),sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2)))+r; printf("%0.2f %0.2f\n",t,t2); continue; } double k=(y1-y2)/(x1-x2); double b=y1-k*x1; double d=abs(k*x3-y3+b)/sqrt(k*k+1); d-=r; double x=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1)); double y=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2)); double d2=max(x,y)+r; printf("%0.2f %0.2f\n",d,d2); } }