#K81327. Battle Simulation Game
Battle Simulation Game
Battle Simulation Game
In this problem, you are given the health points (HP) and damage values for a hero and a monster. The battle begins with the hero attacking the monster, followed by the monster attacking the hero. This process repeats until one of them is defeated (i.e., their HP falls to zero or below). The hero always attacks first.
During each turn, the program should print messages in the following format:
- When the hero attacks: Hero attacks! Monster loses X HP.
- When the monster attacks: Monster attacks! Hero loses Y HP.
Finally, when one of the characters is defeated, print either Hero wins!
or Monster wins!
as the result of the battle.
inputFormat
The input consists of four integers provided via standard input spread over two lines.
The first line contains two space-separated integers representing the hero's health points and damage, respectively.
The second line contains two space-separated integers representing the monster's health points and damage, respectively.
outputFormat
Print each event of the battle simulation on a new line. The events must be printed exactly in the following order:
1. When the hero attacks, print: Hero attacks! Monster loses X HP.
2. If the monster is still alive, print: Monster attacks! Hero loses Y HP.
3. Continue until one of the participants has HP ≤ 0. Then, print either Hero wins!
or Monster wins!
to indicate the outcome.## sample
30 10
25 12
Hero attacks! Monster loses 10 HP.
Monster attacks! Hero loses 12 HP.
Hero attacks! Monster loses 10 HP.
Monster attacks! Hero loses 12 HP.
Hero attacks! Monster loses 10 HP.
Hero wins!
</p>