And while Mishka is enjoying her trip...
Chris is a little brown bear. No one knows, where and when he met Mishka, but for a long time they are together (excluding her current trip). However, best friends are important too. John is Chris' best friend.
Once walking with his friend, John gave Chris the following problem:
At the infinite horizontal road of width w, bounded by lines y = 0 and y = w, there is a bus moving, presented as a convex polygon of nvertices. The bus moves continuously with a constant speed of v in a straight Ox line in direction of decreasing x coordinates, thus in time only x coordinates of its points are changing. Formally, after time t each of x coordinates of its points will be decreased by vt.
There is a pedestrian in the point (0, 0), who can move only by a vertical pedestrian crossing, presented as a segment connecting points (0, 0) and (0, w) with any speed not exceeding u. Thus the pedestrian can move only in a straight line Oy in any direction with any speed not exceeding u and not leaving the road borders. The pedestrian can instantly change his speed, thus, for example, he can stop instantly.
Please look at the sample note picture for better understanding.
We consider the pedestrian is hit by the bus, if at any moment the point he is located in lies strictly inside the bus polygon (this means that if the point lies on the polygon vertex or on its edge, the pedestrian is not hit by the bus).
You are given the bus position at the moment 0. Please help Chris determine minimum amount of time the pedestrian needs to cross the road and reach the point (0, w) and not to be hit by the bus.
The first line of the input contains four integers n, w, v, u (3 ≤ n ≤ 10 000, 1 ≤ w ≤ 109, 1 ≤ v, u ≤ 1000) — the number of the bus polygon vertices, road width, bus speed and pedestrian speed respectively.
The next n lines describes polygon vertices in counter-clockwise order. i-th of them contains pair of integers xi and yi ( - 109 ≤ xi ≤ 109, 0 ≤ yi ≤ w) — coordinates of i-th polygon point. It is guaranteed that the polygon is non-degenerate.
Print the single real t — the time the pedestrian needs to croos the road and not to be hit by the bus. The answer is considered correct if its relative or absolute error doesn't exceed 10 - 6.
5 5 1 2 1 2 3 1 4 3 3 4 1 4
5.0000000000
Following image describes initial position in the first sample case:

有一个N变形巨丑的车如图,问一个人从(0.0)到(0.w)的最小时间是多少。
分情况讨论呗。
① 人非常快 秒男,车没过来人就走了。 这样时间是w/u
②人不行,去了就是送死,那就等车过去,在过去 这样的时间就是max/v+w/u
③就是车已经过去了 直接过去就好了 时间就是w/u
注意精度问题就行了
#include<stdio.h>
#include<iostream>
#include <algorithm>
#include<string.h>
#include<vector>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
#include<set>
#define ll long long
#define INF 0x3f3f3f3f
#define eps 1e-8
const int mod = 1e9+7;
using namespace std;
int KGCD(int a,int b){if(a==0)return b;if(b==0)return a;if(~a&1){ if(b&1) return KGCD(a>>1,b);else return KGCD(a>>1,b>>1) <<1; } if(~b & 1) return KGCD(a, b>>1); if(a > b) return KGCD((a-b)>>1, b);return KGCD((b-a)>>1, a);}
int LCM(int a,int b){ return a/KGCD(a,b)*b; }
inline ll qpow(ll n,ll m){n%=mod;ll ans=1;while(m){if(m%2) ans=(ans*n)%mod;m/=2;n=(n*n)%mod;}return ans;}
inline ll inv(ll b){return b==1?1:(mod-mod/b)*inv(mod%b)%mod;}
inline ll inv2(ll b){return qpow(b,mod-2);}
int dir[5][2]={0,1,0,-1,1,0,-1,0};
int main()
{
double n,w,v,u;
scanf("%lf%lf%lf%lf",&n,&w,&v,&u);
double min1=INF*1.0;
double max1=-INF*1.0;
for(int i=0;i<n;i++)
{
double x,y;
scanf("%lf%lf",&x,&y);
min1=min(min1,x-y/u*v);
max1=max(max1,x-y/u*v);
}
if(min1>=-eps)
printf("%.10lf\n",w/u);
else if(max1>=eps)
printf("%.10lf\n",max1/v+w/u);
else
printf("%.10lf\n",w/u);
return 0;
}

本文探讨了一个人如何在限定时间内安全穿过一条无限水平道路的问题,该道路上有一辆连续移动的巴士。通过分析巴士的位置和速度,行人需找到最优路径及时到达对岸而不被巴士撞到。文章提供了一个解决方案,并考虑了不同情况下行人穿越街道的最佳策略。
1352

被折叠的 条评论
为什么被折叠?



