题解 | 绕距
绕距
https://www.nowcoder.com/practice/7a245fc6284f4139b4fb21de58e68483
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
double x,y,z,w;
cin>>x>>y>>z>>w;
double e,m,d1,d2;
e=sqrt((x-z)*(x-z)+(y-w)*(y-w));
if(x-z<0){
d1=z-x;
}
else{
d1=x-z;
}
if(y-w<0){
d2=w-y;
}
else{
d2=y-w;
}
m=d1+d2;
if(m-e<0){
cout<<fixed<<setprecision(18)<<e-m;
}
else{
cout<<fixed<<setprecision(18)<<m-e;
}
return 0;
}
// 64 位输出请用 printf("%lld")
