CF163C.Conveyor
提高+/省选-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Anton came to a chocolate factory. There he found a working conveyor and decided to run on it from the beginning to the end.
The conveyor is a looped belt with a total length of 2_l_ meters, of which l meters are located on the surface and are arranged in a straight line. The part of the belt which turns at any moment (the part which emerges from under the floor to the surface and returns from the surface under the floor) is assumed to be negligibly short.
The belt is moving uniformly at speed _v_1 meters per second. Anton will be moving on it in the same direction at the constant speed of _v_2 meters per second, so his speed relatively to the floor will be _v_1 + _v_2 meters per second. Anton will neither stop nor change the speed or the direction of movement.
Here and there there are chocolates stuck to the belt (n chocolates). They move together with the belt, and do not come off it. Anton is keen on the chocolates, but he is more keen to move forward. So he will pick up all the chocolates he will pass by, but nothing more. If a chocolate is at the beginning of the belt at the moment when Anton starts running, he will take it, and if a chocolate is at the end of the belt at the moment when Anton comes off the belt, he will leave it.
The figure shows an example with two chocolates. One is located in the position _a_1 = l - d, and is now on the top half of the belt, the second one is in the position a_2 = 2_l - d, and is now on the bottom half of the belt.
You are given the positions of the chocolates relative to the initial start position of the belt 0 ≤ a_1 < a_2 < ... < a__n < 2_l. The positions on the belt from 0 to l correspond to the top, and from l to 2_l — to the the bottom half of the belt (see example). All coordinates are given in meters.
Anton begins to run along the belt at a random moment of time. This means that all possible positions of the belt at the moment he starts running are equiprobable. For each i from 0 to n calculate the probability that Anton will pick up exactly i chocolates.
安东来到了一家巧克力工厂。在那里,他发现了一条正在运行的传送带,并决定从起点跑到终点。
该传送带是一条环形传送带,总长度为 2l 米,其中 l 米位于地表之上,呈一条直线排列。传送带在任意时刻发生转向的部分(即从地板下方升至地表、以及从地表返回地板下方的部分)被假定为可忽略不计的极短长度。
传送带以恒定速度 v1 米/秒匀速运动。安东将在传送带上朝相同方向以恒定速度 v2 米/秒奔跑,因此他相对于地面的速度为 v1+v2 米/秒。安东既不会停下,也不会改变其速度或运动方向。
传送带上零星粘着一些巧克力(共 n 颗),它们随传送带一同运动且不会脱落。安东很喜欢巧克力,但他更热衷于向前奔跑。因此,他只会拾取自己在奔跑过程中经过的所有巧克力,而不会多拿一颗。若某颗巧克力恰好位于传送带起点处(位置 0),且此时安东恰好开始奔跑,则他会拾取这颗巧克力;若某颗巧克力恰好位于传送带终点处(位置 l),且此时安东恰好离开传送带,则他将不会拾取这颗巧克力。
图中给出了一个含两颗巧克力的示例:第一颗位于位置 a1=l−d,当前处于传送带的上半段;第二颗位于位置 a2=2l−d,当前处于传送带的下半段。
已知各颗巧克力相对于传送带初始起点的位置:0≤a1<a2<⋯<an<2l。传送带上位置区间 [0,l] 对应上半段,区间 [l,2l] 对应下半段(参见示例)。所有坐标单位均为米。
安东在某一随机时刻开始沿传送带奔跑,这意味着他在开始奔跑时传送带所处的所有可能位置是等概率的。请对每个 i(从 0 到 n),计算安东恰好拾取 i 颗巧克力的概率。
输入格式
The first line contains space-separated integers n, l, _v_1 and _v_2 (1 ≤ n ≤ 105, 1 ≤ l, _v_1, _v_2 ≤ 109) — the number of the chocolates, the length of the conveyor's visible part, the conveyor's speed and Anton's speed.
The second line contains a sequence of space-separated integers _a_1, _a_2, ..., a__n (0 ≤ _a_1 < a_2 < ... < a__n < 2_l) — the coordinates of the chocolates.
第一行包含用空格分隔的整数 n、l、v1 和 v2(1 ≤ n ≤ 105,1 ≤ l,v1,v2 ≤ 109)——分别表示巧克力的数量、传送带可见部分的长度、传送带的速度以及安东的速度。
第二行包含一个用空格分隔的整数序列 a1,a2,...,an(0 ≤ a1 < a2 < ... < an < 2l)——表示巧克力的坐标。
输出格式
Print n + 1 numbers (one per line): the probabilities that Anton picks up exactly i chocolates, for each i from 0 (the first line) to n (the last line). The answer will be considered correct if each number will have absolute or relative error of at most than 10 - 9.
输出 n+1 个数字(每行一个):Anton 恰好取到 i 块巧克力的概率,其中 i 从 0(第一行)到 n(最后一行)。若每个数字的绝对误差或相对误差均不超过 10−9,则答案视为正确。
输入输出样例
输入#1
1 1 1 1 0
输出#1
0.75000000000000000000 0.25000000000000000000
输入#2
2 3 1 2 2 5
输出#2
0.33333333333333331000 0.66666666666666663000 0.00000000000000000000
说明/提示
In the first sample test Anton can pick up a chocolate if by the moment he starts running its coordinate is less than 0.5; but if by the moment the boy starts running the chocolate's coordinate is greater than or equal to 0.5, then Anton won't be able to pick it up. As all positions of the belt are equiprobable, the probability of picking up the chocolate equals
, and the probability of not picking it up equals
.
在第一个样例测试中,安东只有在开始奔跑时巧克力的坐标小于 0.5 的情况下才能捡起该巧克力;但如果男孩开始奔跑时巧克力的坐标大于或等于 0.5,则安东将无法捡起它。由于传送带上所有位置是等概率的,因此捡起巧克力的概率为
,而未能捡起巧克力的概率为
。
输入解题思路,AI测评打分。不知道怎么写?