B. The Modcrab

Problem - B - Codeforces

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.

Examples

input

Copy

10 6 100
17 5

output

Copy

4
STRIKE
HEAL
STRIKE
STRIKE

input

Copy

11 6 100
12 5

output

Copy

2
STRIKE
STRIKE

Note

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.

沃瓦又在玩一个RPG游戏。在游戏里沃瓦扮演的角色收到了一个任务:去干死一只叫做魔之蟹的大 Boss。

在打了两个小时游戏后沃瓦知道了魔之蟹的各种数值。魔之蟹有 h_2h2​ 点生命值和 a_2a2​ 点攻击力。沃瓦是个手残,他不想死那么多回,于是就去商店氪了一大堆强力生命回复药剂来准备战斗。

沃瓦的角色有 h_1h1​ 点初始生命和 a_1a1​ 点攻击力。他还有无限多的强力生命回复药剂,每一瓶都可以给他回复 c_1c1​ 点血。沃瓦的每一瓶药剂都是完全一样的。题目数据可以保证 c_1 > a_2c1​>a2​ 。

战斗包含多个回合。在沃瓦的回合中,它既可以攻击魔之蟹(可以将他的生命值减少 a_1a1​ ),也可以喝下一瓶药剂(可将沃瓦的生命值增加 c_1c1​ ,沃瓦的生命值值可以超过 h_1h1​ )。现在如果沃瓦和魔之蟹都没有死的话,魔之蟹就会攻击沃瓦,将沃瓦的生命值减少 a_2a2​ 。战斗会在沃瓦或魔之蟹中任意一方死亡后结束。

当然,沃瓦想赢,而且他还想赢的越快越好。所以他想制作一个让他用最短时间获胜的策略。

帮帮沃瓦把策略写出来吧!你可以假设沃瓦有无数瓶药水,而且测试数据能保证沃瓦总能赢。

输入输出格式

输入格式

第一行包含三个正整数h_1h1​, a_1a1​, c_1c1​ (1 \leq h_1, a_1 \leq 1001≤h1​,a1​≤100)(2\leq c_1\leq 1002≤c1​≤100),分别代表沃瓦的初始生命值,沃瓦的攻击力和一瓶强效生命药剂能回复的生命值。

第二行包含两个正整数 h_2h2​, a_2a2​ (1\leq h2\leq 1001≤h2≤100)(1\leq a_2, c_11≤a2​,c1​),分别代表魔之蟹的生命值和攻击力。

输出格式

在第一行输出一个正整数 nn,代表赢得战斗需要的最少回合数。

接下来输出 nn 行。第 ii 行可以是代表沃瓦在这回合中喝了一瓶生命药剂的 HEAL,也可以是代表沃瓦在这回合中攻击了魔之蟹的 STRIKE

必胜策略必须满足以下条件:沃瓦的角色必须在死亡之前击败魔之蟹,在沃瓦进行最后的操作后魔之蟹的生命值必须小于等于 00。

如果有多组解,输出任意一组即可。

#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<cmath>
#include<string.h>
using namespace std;
// ctrl+shift+C 注释
//ctrl+shift+x 取消
#define int long long
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef pair<int,int> PII;
const int N=2e5+10;
const ll M=1e18+10;
const int mod=1e9+7;
int a[N],sum[N];
priority_queue<int,vector<int>,greater<int> >pq;
set<int>se;
map<int,int>mp;
queue<int>qu;
vector<string>v;
deque<int>de;
int h1,a1,c1,h2,a2;
void solve()
{
   cin>>h1>>a1>>c1;
   cin>>h2>>a2;
   int k=1;
   while(h1>0&&h2>0)
   {
       if(k)
      {
          if(h1<=a2&&h2>a1)//打一次,如果怪不会死在自己前面,那么还是补血比较划算      
         {
           h1+=c1;
           v.push_back("HEAL");
         }
         else
         {
           h2-=a1;
           v.push_back("STRIKE");
         }

      }
      else
      {
         h1-=a2;
      }
        k^=1;//代表一个轮回标志
   }
   cout<<v.size()<<endl;
   for(int i=0;i<v.size();i++)
   {
       cout<<v[i]<<endl;
   }
}
signed main()
{
   int t=1;
   //cin>>t;
   while(t--)
   {
       solve();
   }
}

国庆假就没了 T....T

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值