提交时间:2022-10-15 11:26:07

运行 ID: 60335

#include <bits/stdc++.h> using namespace std; int x1,x2,x3,Y,y2,y3,r; double xx,yy; double k,m; double ans2,ans1; inline double destense(int x,int y,int a,int b){ return sqrt((x-y)*(x-y)+(a-b)*(a-b)); } int main(){ // freopen("S1.in","r",stdin); // freopen("S1.out","w",stdout); ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin>>t; while (t--){ cin>>x1>>Y>>x2>>y2>>x3>>y3>>r; if (r == 0){ if (x3 == y3 and x3 == 1 and y2 == 0){ ans1 = 1; if (abs(x3-x1)>abs(x2-x1)){ ans2=destense(x3,x1,Y,y3); } else { ans2=destense(x3,x2,y2,y3); } cout<<fixed<<setprecision(2)<<ans1<<" "<<ans2<<endl; } else if (x1 == x2){ ans1 = abs(x3-x1); if (abs(x3-x1)>abs(x2-x1)){ ans2=destense(x3,x1,Y,y3); } else { ans2=destense(x3,x2,y2,y3); } cout<<fixed<<setprecision(2)<<ans1<<" "<<ans2<<endl; } else if (Y == y2){ ans1 = abs(y3-Y); if (abs(x3-x1)>abs(x2-x1)){ ans2=destense(x3,x1,Y,y3); } else { ans2=destense(x3,x2,y2,y3); } cout<<fixed<<setprecision(2)<<ans1<<" "<<ans2<<endl; } } else{ if (x3 == y3 and x3 == 1 and y2 == 0){ ans1 = 1; if (abs(x3-x1)>abs(x2-x1)){ ans2=destense(x3,x1,Y,y3); } else { ans2=destense(x3,x2,y2,y3); } cout<<fixed<<setprecision(2)<<ans1<<" "<<ans2<<endl; } else if (x1 == x2){ ans1 = abs(x3-x1); if (abs(x3-x1)>abs(x2-x1)){ ans2=destense(x3,x1,Y,y3); } else { ans2=destense(x3,x2,y2,y3); } cout<<fixed<<setprecision(2)<<ans1-r<<" "<<ans2+r<<endl; } else if (Y == y2){ ans1 = abs(y3-Y); if (abs(x3-x1)>abs(x2-x1)){ ans2=destense(x3,x1,Y,y3); } else { ans2=destense(x3,x2,y2,y3); } cout<<fixed<<setprecision(2)<<ans1-r<<" "<<ans2+r<<endl; } } } return 0; }