1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#include<bits/stdc++.h> using namespace std; #define Debug(x) cout<<#x<<':'<<x<<endl #define INF 0x7fffffff typedef long long ll; typedef long double ld; typedef pair<ll,ll> P; const ll maxn=2e5+11; ld x,x1,v1,x2,v2,ans; void load(ld xx){ ans=min(ans,xx); } void solve(){ ld xx=min(x+x1,x-x1+x); load(xx/v1); xx=min(x+x-x2,x+x2); load(xx/v2); ld tt=max((x-x1)/v1,x2/v2); load(tt); ld l=x1,r=x2; while(r-l>1e-12){ ld mid=(l+r)/2; ld t1=min(x1+mid,mid+mid-x1)/v1; ld t2=min(x-mid+x2-mid,x-mid+x-x2)/v2; if(t1<t2) l=mid; else r=mid; } ld t1=min(x1+l,l+l-x1)/v1; ld t2=min(x-l+x2-l,x-l+x-x2)/v2; load(max(t1,t2)); printf("%.10LF\n",ans); } int main(){ ll ca;cin>>ca; while(ca--){ scanf("%Lf%Lf%Lf%Lf%Lf",&x,&x1,&v1,&x2,&v2); if(x1>x2){ swap(x1,x2);swap(v1,v2); } ans=1e12; solve(); } return 0; }
|