提交时间:2022-10-15 11:31:20

运行 ID: 60413

#include<stdio.h> #include<cmath> using namespace std; #define max(a,b) ((a)>(b)?(a):(b)) #define distance(x1,y1,x2,y2) (sqrt(((x1)-(x2))*((x1)-(x2))+((y1)-(y2))*((y1)-(y2)))) int main(){ // freopen("sample1.in","r",stdin); int n,x1,y1,x2,y2,x3,y3,r; scanf("%d",&n); for(int i=0;i<n;++i){ scanf("%d%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3,&r); // printf("%d %d %d %d %d %d %d\n",x1,y1,x2,y2,x3,y3,r); double k1=(y1-y2)*1.0/(x1-x2),b1=y1-k1*x1,k2=-1/k1,b2=y3-k2*x3,x=(b1-b2)/(k2-k1),y=(b1-b2)/(k2-k1)*k1+b1; printf("%.2lf %.2lf\n",(x1==x2?x3-x1:y1==y2?y3-y1:distance(x3,y3,x,y))-r,max(distance(x1,y1,x3,y3),distance(x2,y2,x3,y3))+r); // printf("%.2lf %.2lf %.2lf %.2lf %.2lf %.2lf",k1,b1,k2,b2,x,y); } }