AtCoder Beginner Contest 224
G
Roll or Increment
AtCoder
⌀ 2374
原题
←H →
翻译中…

Problem Statement

翻译中…

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.

翻译中…
  • Pay $A$ yen (the Japanese currency) to "increase" the value shown by the die by $1$, that is, reposition it to show $X+1$ when it currently shows $X$. This operation cannot be done when the die shows $N$.
  • Pay $B$ yen to recast the die, after which it will show an integer between $1$ and $N$ with equal probability.
翻译中…

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.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 10^9$
  • $1 \leq S, T \leq N$
  • $1 \leq A, B \leq 10^9$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N S T A B

翻译中…

Output

翻译中…

Print the answer. Your output will be considered correct when its absolute or relative error is at most $10^{-5}$.

翻译中…

样例

Input #1
5 2 4 10 4
Output #1
15.0000000000000000
When the optimal strategy is used to minimize the expected cost, it will be $15$ yen.
Input #2
10 6 6 1 2
Output #2
0.0000000000000000
The die already shows $T$ in the initial state, which means no operation is needed.
Input #3
1000000000 1000000000 1 1000000000 1000000000
Output #3
1000000000000000000.0000000000000000
Your output will be considered correct when its absolute or relative error is at most $10^{-5}$.
题目信息
题号
abc224_g
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。