VS

Alice and Bob are having a Pokemon battle. Knowing that Bob uses Gyarados, Alice chose Blissey, as she knows that Blissey will win the battle.

In this Pokemon battle, both Gyarados and Blissey has an intial HP. And when one of the Pokemon's HP reached $\lt 0$, the other one wins.

Why must Blissey be the winner? Because Alice uses a secret strategy...

Firstly, Alice knows that Bob will tell Gyarados to use the attack “Hyper Beam”, and it causes $X$ damage to Blissey, which means Blissey’s HP is decreased by $X$, and Blissey has an original HP of $Y$. Alices lets Gyarados launch “Hyper Beam” until Blissey reaches an HP $\lt X$. As Alice knows that $Y \gt X$, she can let Gyarados launch "Hyper Beam" at least once and becomes exhausted. Then, let $H$ be the remaining HP of Blissey, Alice uses a potion which heals $Y - H$ HP from Blissey. Finally, Alice orders Blissey to use “Hyper Beam”, and with the very poor defence of Gyrados, Blissey wins the battle without any damage.

However, a potion that heals $T$ HP requires Alice $aT^2 + bT + c$ minutes to make it, where $a$, $b$ and $c$ are given constants. Given $a$, $b$, $c$, $X$ and $Y$, help Alice calculate the number of minutes needed to prepare the potion.

Input

The first line of the input contains two positive integers $X$ and $Y$. ($1 \le X \lt Y \le 100$)
The second line of the input contains three positive integers $a$, $b$ and $c$. ($0 \le a,b,c \le 100$)

Output

Output the number of minutes needed for Alice to prepare the potion.

Hint

You DON’T have to use for-loop / while-loop in this task -_-
Simple math can work :)

Subtasks

Subtask 1: $a = b = 0$ (15 pts)
Subtask 2: $X = 1$ (15 pts)
Subtask 3: $X = 3, Y = 35$ (15 pts)
Subtask 4: $X = 4, Y = 55$ (15 pts)
Subtask 5: $a = c = 0$ (20 pts)
Subtask 6: No additional constraints (20 pts)

Sample Test Cases

Input Output
3 8
1 2 3
51

First, Gyarados launches the first “Hyper Beam”, Blissey’s HP decreased from $8$ to $8 - 3 = 5$
Then, Gyarados launches the second “Hyper Beam”, Blissey’s HP decreased from $5$ to $5 - 3 = 2$
After that, as Blissey’s HP $= 2 \lt 3$, Alice uses the potion.
Therefore, we know that the potion heals $8 - 2 = 6$ HP from Blissey, after substituting 6 into the formula $aT^2 + bT + c$, which is $1T^2 + 2T + 3$ with the given $a$, $b$ and $c$, $1(6)^2 + 2(6) + 3 = 51$ minutes is needed

 
5 17
1 1 1
241

First, Gyarados launches the first “Hyper Beam”, Blissey’s HP decreased from $17$ to $17 - 5 = 12$
Then, Gyarados launches the second “Hyper Beam”, Blissey’s HP decreased from $12$ to $12 - 5 = 7$
Then, Gyarados launches the third “Hyper Beam”, Blissey’s HP decreased from $7$ to $7 - 5 = 2$
After that, as Blissey’s HP $= 2 \lt 5$, Alice uses the potion.
Therefore, we know that the potion heals $17 - 2 = 15$ HP from Blissey, after substituting 6 into the formula $aT^2 + bT + c$, which is $1T^2 + 1T + 1$ with the given $a$, $b$ and $c$, $1(15)^2 + 1(15) + 1 = 241$ minutes is needed

Click to copy.

Scoring: Per Subtask
Authored by wy24215
Appeared in WYHK 2026 Mini Comp 0 🗣️🙊🇫🇷🥖🤮 🟥🟦3️⃣2️⃣1️⃣🎊 8️⃣0️⃣🧙‍♀️ 🇩🇪🏙️🌍🦠🧑‍💻💃🌧️