SP10683 BYTESB - DRIVE
Description
Black Widow needs to get to the Avengers’ aid and fast. Stark may have lent her his new Audi but she forgot to fuel it up (people make all kinds of stupid mistakes, but if they look like Scarlet Johansson, who cares?). She needs to cross the next hill to get to her team but there’s only a little fuel left. So, obviously she’ll take the most efficient route. However, some parts of this route go uphill, some go downhill – each part with a different slope and different length.
The fuel expenditure (per unit distance travelled) increases linearly with the driving speed v but there’s also an offset that depends on the slope s of the hill – let’s say when going downhill on a particular road, she might be able to go at 8 km/h without expending any fuel on the other hand, if she were to travel that same road uphill, she would expend fuel at the same rate as if she were driving 8 km/h faster along a flat road.
The car’s fuel consumption c in litres per kilometer is given by
c = max(0; a\*v + b\*s); (1)
where
a : fuel expenditure rate on a flat road
v : speed in km/h
s : inclination of the road
b : positive constant
Acceleration and deceleration are instantaneous and do not cost any fuel.
There is also a safe speed limit that she can’t exceed. How quickly can she get there?
Input
On the first line a positive integer: the number of test cases, at most 100. After that per test case:
One line with four floating point numbers a(0.1
Input Format
N/A
Output Format
N/A