CodeForces - 903B 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

Examples

Input

10 6 100
17 5

Output

4
STRIKE
HEAL
STRIKE
STRIKE

Input

11 6 100
12 5

 

Output

2
STRIKE
STRIKE

 

题意:

玩家有三个属性:生命值h1,攻击力a1,喝一瓶药剂增加生命值c1(药剂视为无限)

怪物有两个属性:生命值h2,攻击力a2

在每一回合:

玩家可以选择喝药或攻击怪物(只能选择一个操作)

怪物只会攻击玩家

输出玩家在获胜的情况下,所需的最小回合数;

并输出每回合玩家的操作(STRIKE 或者 HEAL)

 

 

好气好气(╯-_-)╯╧╧,数组开小了,判我时间超限(为什么是时间超限啊)

下次数组开大点

 

贪心,在下一次怪物能打死玩家 并且 玩家不能打死怪物 的情况 ,玩家就要喝药剂了,否则,就尽可能的攻击

 

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <vector>
#include <numeric>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define eps 1e-8
#define PI acos(-1)
#define INF 0x3f3f3f3f
using namespace std;
const int N=20000 + 10 ;
typedef long long int LL;
const int dir[4][2]= { {1,0},{0,1},{-1,0},{0,-1} };

int GCD(int a,int b)
{
    return b ? GCD(b,a%b) : a;
}


int main()
{
    int i,h1,a1,c1,h2,a2,cou=0,g=0;
    int ans[N]={0};
    scanf("%d%d%d%d%d",&h1,&a1,&c1,&h2,&a2);
    while(h2>0)
    {
        if(h1<=a2)
        {
            if(a1>=h2)
            {
                cou++;
                ans[g++]=2;
                break;
            }
            else{
                h1+=c1;
                ans[g++]=1;
            }
        }
        else
        {
            h2-=a1;
            ans[g++]=2;
        }
        h1-=a2;
        cou++;
    }
    printf("%d\n",cou);
    for(i=0;i<g;i++)
    {
        if(ans[i]==1)
            printf("HEAL\n");
        else
            printf("STRIKE\n");
    }

    return 0;
}

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值