6 Fear of the Dark

发布时间 2024-01-09 20:48:31作者: yufan1102

image
image
image

题目是一定有答案的,说明所有的情况都是可行的,那么就会有两种情况

1 两个圆都包括了起点和终点

2 一个原包括了起点,另一个原包括了终点(圆一定是相交的)

#include<bits/stdc++.h>
using namespace std;
double dx(int x1,int y1,int x2,int y2){
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
void solve(){
	int ex,ey,x1,x2,y1,y2;
	cin>>ex>>ey>>x1>>y1>>x2>>y2;
	double k=dx(x1,y1,x2,y2)/2; 
	double a=dx(x1,y1,0,0);
	double b=dx(x1,y1,ex,ey);
	double c=dx(x2,y2,0,0);
	double d=dx(x2,y2,ex,ey);
	double ans=min({
	max(a,b),
	max(c,d),
	max({a,k,d}),
	max({c,k,b}),
	});
	cout<<fixed<<setprecision(10)<<ans<<"\n"; 
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int t=1;
	cin>>t;
	for(int i=1;i<=t;i++)solve();
	return 0;
}