A11564 | The Modcrab
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Vova is again playing some computer game, now an RPG. In the game Vova's character received a quest: to slay the fearsome monster called Modcrab.
After two hours of playing the game Vova has tracked the monster and analyzed its tactics. The Modcrab has $h_{2}$ health points and an attack power of $a_{2}$ . Knowing that, Vova has decided to buy a lot of strong healing potions and to prepare for battle.
Vova's character has $h_{1}$ health points and an attack power of $a_{1}$ . Also he has a large supply of healing potions, each of which increases his current amount of health points by $c_{1}$ when Vova drinks a potion. All potions are identical to each other. It is guaranteed that $c_{1}>a_{2}$ .
The battle consists of multiple phases. In the beginning of each phase, Vova can either attack the monster (thus reducing its health by $a_{1}$ ) or drink a healing potion (it increases Vova's health by $c_{1}$ ; Vova's health can exceed $h_{1}$ ). Then, if the battle is not over yet, the Modcrab attacks Vova, reducing his health by $a_{2}$ . The battle ends when Vova's (or Modcrab's) health drops to $0$ or lower. It is possible that the battle ends in a middle of a phase after Vova's attack.
Of course, Vova wants to win the fight. But also he wants to do it as fast as possible. So he wants to make up a strategy that will allow him to win the fight after the minimum possible number of phases.
Help Vova to make up a strategy! You may assume that Vova never runs out of healing potions, and that he can always win.
After two hours of playing the game Vova has tracked the monster and analyzed its tactics. The Modcrab has $h_{2}$ health points and an attack power of $a_{2}$ . Knowing that, Vova has decided to buy a lot of strong healing potions and to prepare for battle.
Vova's character has $h_{1}$ health points and an attack power of $a_{1}$ . Also he has a large supply of healing potions, each of which increases his current amount of health points by $c_{1}$ when Vova drinks a potion. All potions are identical to each other. It is guaranteed that $c_{1}>a_{2}$ .
The battle consists of multiple phases. In the beginning of each phase, Vova can either attack the monster (thus reducing its health by $a_{1}$ ) or drink a healing potion (it increases Vova's health by $c_{1}$ ; Vova's health can exceed $h_{1}$ ). Then, if the battle is not over yet, the Modcrab attacks Vova, reducing his health by $a_{2}$ . The battle ends when Vova's (or Modcrab's) health drops to $0$ or lower. It is possible that the battle ends in a middle of a phase after Vova's attack.
Of course, Vova wants to win the fight. But also he wants to do it as fast as possible. So he wants to make up a strategy that will allow him to win the fight after the minimum possible number of phases.
Help Vova to make up a strategy! You may assume that Vova never runs out of healing potions, and that he can always win.
输入格式
The first line contains three integers $h_{1}$ , $a_{1}$ , $c_{1}$ ( $1<=h_{1},a_{1}<=100$ , $2<=c_{1}<=100$ ) — Vova's health, Vova's attack power and the healing power of a potion.
The second line contains two integers $h_{2}$ , $a_{2}$ ( $1<=h_{2}<=100$ , $1<=a_{2}<c_{1}$ ) — the Modcrab's health and his attack power.
The second line contains two integers $h_{2}$ , $a_{2}$ ( $1<=h_{2}<=100$ , $1<=a_{2}<c_{1}$ ) — the Modcrab's health and his attack power.
输出格式
In the first line print one integer $n$ denoting the minimum number of phases required to win the battle.
Then print $n$ lines. $i$ -th line must be equal to HEAL if Vova drinks a potion in $i$ -th phase, or STRIKE if he attacks the Modcrab.
The strategy must be valid: Vova's character must not be defeated before slaying the Modcrab, and the monster's health must be $0$ or lower after Vova's last action.
If there are multiple optimal solutions, print any of them.
Then print $n$ lines. $i$ -th line must be equal to HEAL if Vova drinks a potion in $i$ -th phase, or STRIKE if he attacks the Modcrab.
The strategy must be valid: Vova's character must not be defeated before slaying the Modcrab, and the monster's health must be $0$ or lower after Vova's last action.
If there are multiple optimal solutions, print any of them.
输入输出样例
输入 #1
10 6 100 17 5
输出 #1
4 STRIKE HEAL STRIKE STRIKE
输入 #2
11 6 100 12 5
输出 #2
2 STRIKE STRIKE
In the first example Vova's character must heal before or after his first attack. Otherwise his health will drop to zero in $2$ phases while he needs $3$ strikes to win.
In the second example no healing needed, two strikes are enough to get monster to zero health and win with $6$ health left.
In the second example no healing needed, two strikes are enough to get monster to zero health and win with $6$ health left.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted