# bzoj1857 [ SCOI2010 ] -- 三分套三分

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
#define Eps 1e-3
struct Node{
double x,y;
Node(){}
Node(double x,double y):x(x),y(y){}
Node operator + (Node a){return Node(x+a.x,y+a.y);}
Node operator - (Node a){return Node(x-a.x,y-a.y);}
Node operator / (double a){return Node(x/a,y/a);}
}a,b,c,d,l,r,m1,m2;
int i,j,k,n,m,p,v1,v2,v3;
inline double Dis(Node a,Node b){
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
inline double Get(Node a,Node b,Node c,Node d){
return Dis(a,b)/v1+Dis(b,c)/v3+Dis(c,d)/v2;
}
inline double Calc(Node x){
Node l=c,r=d,m1,m2;
while(Dis(l,r)>Eps){
m1=(r-l)/3;m2=r-m1;m1=l+m1;
if(Get(a,x,m1,d)>Get(a,x,m2,d))l=m1;else r=m2;
}
return Get(a,x,l,d);
}
int main(){
scanf("%d%d%d",&v1,&v2,&v3);
l=a;r=b;
while(Dis(l,r)>Eps){
m1=(r-l)/3;m2=r-m1;m1=l+m1;
if(Calc(m1)>Calc(m2))l=m1;else r=m2;
}
printf("%.2lf\n",Calc(l));
return 0;
}
bzoj1857

posted @ 2017-05-19 17:02  gjghfd  阅读(279)  评论(0编辑  收藏  举报