模拟退火解法
#include<bits/stdc++.h>
#define down 0.95
#define int double
using namespace std;
double x,y,xx,yy,xxx,yyy,ans,l,r,s,ansp;
double get(int Xx,int Yx,int XXx,int YYx){
return 1.000*sqrt(1.000*(Xx-XXx)*(Xx-XXx)+1.000*(Yx-YYx)*(Yx-YYx));
}
double gets(int X,int Y,int XX,int YY,int XXX,int YYY){
double l1,l2,l3,p;
l1=get(X,Y,XX,YY);
l2=get(X,Y,XXX,YYY);
l3=get(XX,YY,XXX,YYY);
p=(l1+l2+l3)*0.500000;
return 1.000*sqrt(1.0000*p*(p-l1)*(p-l2)*(p-l3));
}
void sa(){
double T=3000;
while(T>1e-15){
double sp=max(l,min(ansp+(2*rand()-RAND_MAX)*T,r));
double reans=gets(x+sp*(xx-x),y+sp*(yy-y),xx+sp*(xxx-xx),yy+sp*(yyy-yy),xxx+sp*(x-xxx),yyy+sp*(y-yyy));
if(reans<ans){
ans=reans;
ansp=sp;
}
else if(exp(-(reans-ans)/T)*RAND_MAX>rand()){
ansp=sp;
}
T*=down;
}
return;
}
signed main(){
cin>>l>>r>>x>>y>>xx>>yy>>xxx>>yyy;
s=gets(x,y,xx,yy,xxx,yyy);
ans=gets(x+ansp*(xx-x),y+ansp*(yy-y),xx+ansp*(xxx-xx),yy+ansp*(yyy-yy),xxx+ansp*(x-xxx),yyy+ansp*(y-yyy));
for(int i=1;i<=100;++i)sa();
cout<<ans;
return 0;
}