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$ |
||
| 5 17 1 1 1 |
241 | |
First, Gyarados launches the first “Hyper Beam”, Blissey’s HP decreased from $17$ to $17 - 5 = 12$ |
||
Scoring: Per Subtask
Authored by wy24215
Appeared in WYHK 2026 Mini Comp 0 🗣️🙊🇫🇷🥖🤮 🟥🟦3️⃣2️⃣1️⃣🎊 8️⃣0️⃣🧙♀️ 🇩🇪🏙️🌍🦠🧑💻💃🌧️