Score : $600$ points
We have a $N$-face die (singular of dice) that shows integers from $1$ through $N$ with equal probability.
Below, the die is said to be showing an integer $X$ when it is placed so that the top face is the face with the integer $X$.
Initially, the die shows the integer $S$.
You can do the following two operations on this die any number (possibly zero) of times in any order.
Consider making the die show $T$ from the initial state where it shows $S$.
Print the minimum expected value of the cost required to do so when the optimal strategy is used to minimize this expected value.
Input is given from Standard Input in the following format:
$N$ $S$ $T$ $A$ $B$
Print the answer. Your output will be considered correct when its absolute or relative error is at most $10^{-5}$.
5 2 4 10 4
15.0000000000000000
When the optimal strategy is used to minimize the expected cost, it will be $15$ yen.
10 6 6 1 2
0.0000000000000000
The die already shows $T$ in the initial state, which means no operation is needed.
1000000000 1000000000 1 1000000000 1000000000
1000000000000000000.0000000000000000
Your output will be considered correct when its absolute or relative error is at most $10^{-5}$.