#P4273. Rainwater on the Crosswalk
Rainwater on the Crosswalk
Rainwater on the Crosswalk
In M country, especially in City P, heavy rain often disrupts pedestrians. To ease crossing during rain, authorities have installed devices called "automatic umbrellas" above every pedestrian crossing (see Figure (1)). Each automatic umbrella is approximately a rectangular board whose thickness can be ignored. Its width equals the width of the crossing and its length (which can vary among devices) is less than or equal to the length of the crossing. In dry weather the umbrellas remain idle; when it rains, they immediately start moving back and forth in straight lines at a constant speed. They start from one side (with their left edge at 0) and move to the other side, then reverse direction upon reaching the boundary, and continue so, while never crossing the crossing's boundaries. Moreover, each umbrella absorbs all the rain that falls on it through small holes, so any rain that falls on it is completely removed.
The rain falls uniformly onto the entire crossing with an intensity of (R) (volume per unit area per second). At any time (t), each umbrella (i) (with length (l_i) and speed (v_i)) covers an interval ([x_i(t), x_i(t)+l_i]) along the crosswalk. The position (x_i(t)) is defined by
[
x_i(t) = \begin{cases} v_i t', & \text{if } t' \leq \frac{L-l_i}{v_i}, \[8pt]
(L-l_i) - v_i\Big(t' - \frac{L-l_i}{v_i}\Big), & \text{if } t' > \frac{L-l_i}{v_i},
\end{cases}
]
where (t' = t \bmod \left(\frac{2(L-l_i)}{v_i}\right)) and (L) is the length of the crossing. The union of these intervals represents the area covered (and thus protected) by the umbrellas. The uncovered part of the crossing at time (t) is (L) minus the total covered length (taking overlaps into account).
Your task is to compute the total volume (V) of rainwater that falls on the crossing (i.e. on the uncovered areas) over a time period from (t=0) to (t=T). The answer is given by
[
V = R \cdot W \cdot \int_{0}^{T} \Bigl( L - \text{covered}(t) \Bigr),dt,
]
where (W) is the width of the crossing (which is equal to the umbrella width) and (\text{covered}(t)) is the union length of all umbrella intervals at time (t).
inputFormat
The first line contains five numbers: (T), (L), (W), (R), and (n):
- \(T\): the duration of the rain in seconds.
- \(L\): the length of the pedestrian crossing.
- \(W\): the width of the pedestrian crossing (equal to the umbrella width).
- \(R\): the rain intensity (volume per unit area per second).
- \(n\): the number of automatic umbrellas installed above the crossing.
outputFormat
Output a single real number: the total volume of rainwater that falls on the crossing from (t = 0) to (t = T). Your answer is accepted if its absolute or relative error does not exceed (10^{-6}).
sample
10 10 2 1 1
5 1
40.000000
</p>