企图用切比雪夫距离/曼哈顿距离进行三分判距
企图swap任何一对点
附AC参考
#include <cstdio>
#include <cmath>
#define sq(a) ((a)*(a))
const double eps=1e-13;
struct point{
double x,y;
void read(){
scanf("%lf%lf",&x,&y);
}
}a,b,c,d;
point operator+(const point &a,const point &b){
return (point){a.x+b.x,a.y+b.y};
}
point operator/(const point &a,const int &b){
return (point){a.x/b,a.y/b};
}
double dist(point a,point b){
return sqrt(sq(a.x-b.x)+sq(a.y-b.y));
}
bool operator!=(const point &a,const point &b){
return dist(a,b)>eps;
}
double P,Q,R;
void init(){
a.read(),b.read(),c.read(),d.read();
scanf("%lf%lf%lf",&P,&Q,&R);
}
inline double f1(point e,point f){
return dist(a,e)/P+dist(e,f)/R;
}
double g1(point f){
point l=a,r=b;
while (l!=r){
point mid1=(l+l+r)/3,mid2=(l+r+r)/3;
double y1=f1(mid1,f),y2=f1(mid2,f);
if (y1<y2) r=mid2;
else l=mid1;
}
return f1(l,f);
}
inline double f2(point f){
return g1(f)+dist(f,d)/Q;
}
double g2(){
point l=c,r=d;
while (l!=r){
point mid1=(l+l+r)/3,mid2=(l+r+r)/3;
double y1=f2(mid1),y2=f2(mid2);
if (y1<y2) r=mid2;
else l=mid1;
}
return f2(l);
}
void solve(){
printf("%.2lf",g2());
}
int main(){
init();
solve();
}