题目链接
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
const double PI = 3.141592653589;
double dis(double x1,double y1,double x2,double y2)
{
return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}
signed main()
{
double R,x1,y1,x2,y2;
cin>>R>>x1>>y1>>x2>>y2;
double res=dis(x1,y1,x2,y2);
for(double i=0;i<2*PI;i+=0.000001)
{
double a=R*1.0*cos(i);
double b=R*1.0*sin(i);
res=min(res,dis(a,b,x1,y1)+dis(-a,-b,x2,y2));
}
printf("%.9lf\n",res);
}