B. The Modcrab

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 h2 health points and an attack power of a2. Knowing that, Vova has decided to buy a lot of strong healing potions and to prepare for battle.

Vova's character has h1 health points and an attack power of a1. Also he has a large supply of healing potions, each of which increases his current amount of health points by c1 when Vova drinks a potion. All potions are identical to each other. It is guaranteed that c1 > a2.

The battle consists of multiple phases. In the beginning of each phase, Vova can either attack the monster (thus reducing its health by a1) or drink a healing potion (it increases Vova's health by c1; Vova's health can exceed h1). Then, if the battle is not over yet, the Modcrab attacks Vova, reducing his health by a2. 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.

Input
The first line contains three integers h1, a1, c1 (1 ≤ h1, a1 ≤ 100, 2 ≤ c1 ≤ 100) — Vova's health, Vova's attack power and the healing power of a potion.

The second line contains two integers h2, a2 (1 ≤ h2 ≤ 100, 1 ≤ a2 < c1) — the Modcrab's health and his attack power.

Output
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.

Input

 

Output

STRIKE
HEAL
STRIKE
STRIKE

Input

 

Output

STRIKE
STRIKE

题意:vova要打败一个怪物,vova 的血量h1,攻击力a1,可以无限使用的血瓶c1,可以加c1这么多血,加的血量可以无上限。怪物的血量h2,攻击力a2。

思路:模拟就行。【注意】一开始没考虑,可以一击必杀的那种情况,就是h2怪物血量小于,vova攻击力并且vova血量小于怪物攻击力,其实不用加血的,直接秒杀

AC代码:

 #include<bits/stdc++.h> 

 using namespace std;

 #define int long long
int arr[];
signed main(){
int h1,a1,c1;
int h2,a2;
cin>>h1>>a1>>c1;
cin>>h2>>a2;
if(a1>=h2){
printf("1\nSTRIKE");
return ;
}
int x1=;
int x2=;
if(h2%a1){
x1++;
}
if(h1%a2){
x2++;
}
x1+=h2/a1;
x2+=h1/a2;
if(x2>=x1){
printf("%d\n",x1);
for(int i=;i<x1;i++){
printf("STRIKE\n");
}
return ;
}
int cnt=;
while(){
if((h2-a1<=)){// 【注意】:可以一击必杀的QAQ
arr[cnt++]=;
break;
}
if((h1-a2)<=){
arr[cnt++]=;
h1+=c1;
}else{
h2=h2-a1;
arr[cnt++]=;
if(h2<=){
break;
} }
h1-=a2;
}
printf("%d\n",cnt-);
for(int i=;i<cnt;i++){
if(arr[i]==){
printf("STRIKE\n");
}else{
printf("HEAL\n");
}
}
return ;
}

最新文章

  1. 开源代码分析之Android/iOS Hybrid JSBridge框架
  2. 【编程题目】栈的 push、pop 序列
  3. Html笔记(五)表格
  4. 关于set或map的key使用自定义类型的问题
  5. (中等) HDU 4725 The Shortest Path in Nya Graph,Dijkstra+加点。
  6. dreamweaver中的 map怎么调用?_制作热点图像区域
  7. Linux系统文件的三个重要时间详解
  8. Django进阶篇【1】
  9. 理解ASP.NET Core 依赖注入
  10. Day034--Python--锁, 信号量, 事件, 队列, 生产者消费者模型, joinableQueue
  11. ImportError: No module named &#39;requests.packages.urllib3&#39;
  12. jvm-class文件简介
  13. 2017.11.11日后matlab统一过期需激活解决办法
  14. php中安装memcache
  15. pyhanlp 两种依存句法分类器
  16. [LeetCode] 206. Reverse Linked List_Easy tag: Linked List
  17. Codeforces Round #545 (Div. 1) 简要题解
  18. @JVM中对象的引用类型
  19. SCI EI期刊
  20. 关于token,session,cookie的概念和区别

热门文章

  1. python学习-4 python基础-2 条件语句(if的简单用法1)
  2. Java并发与多线程教程(2)
  3. Docker 启动SQLServer
  4. SpringCloud 随笔
  5. Lab3 Report
  6. mysql in 中使用子查询,会不使用索引而走全表扫描
  7. 聚类算法之MeanShift
  8. C# Winform 禁止一个进程运行多次
  9. 车钥匙开关上找不到+24V的问题 - 岱峰 - DGY90
  10. 区块链火爆,再不知道Golang就晚了