The Modcrab (简单模拟)

20人阅读 评论(0) 收藏 举报

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.


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.


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.

10 6 100
17 5
11 6 100
12 5

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.


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
    int h1,a1,c1;
    int h2,a2;
    cin >> h1 >> a1 >> c1;
    cin >> h2 >> a2;
    int attack = h2 / a1;
    int heal = 0;
    if(attack * a1 < h2) attack++;
    int be_attacked = attack - 1;
    int need = be_attacked * a2 - h1;
    if(need >= 0){
        int add = c1 - a2;
        heal = need / add;
        if(heal * add <= need) heal++;
    return 0;


Codeforces 903B - The Modcrab 模拟+记录

模拟过程并记录 #include #include #include #include #include #include #include #include #include #inclu...
  • xiang_6
  • xiang_6
  • 2017-12-14 13:25:37
  • 185

Educational Codeforces Round 34 (Rated for Div. 2)B. The Modcrab(贪心)

B. The Modcrab time limit per test 1 second memory limit per test 256 megabytes inp...
  • qq_34826781
  • qq_34826781
  • 2018-01-22 21:44:49
  • 26

codeforces 903B. The Modcrab(模拟)

  • ZscDst
  • ZscDst
  • 2017-12-20 20:06:39
  • 193


  • u014376961
  • u014376961
  • 2016-07-22 21:03:40
  • 2242

The Modcrab_Codeforces

原题链接: B. The Modcrab time limit per test 1 sec...
  • qq_34622474
  • qq_34622474
  • 2017-12-13 22:49:08
  • 138

The Modcrab

Vova is again playing some computer game, now an RPG. In the game Vova's character received a quest:...
  • islittlehappy
  • islittlehappy
  • 2018-04-17 16:27:32
  • 5

PTA 7-3(队列) 银行业务队列简单模拟(25 分) 25分代码

。。 (注: 博客作为交流使用,请勿抄袭应付作业) #include #include #include #include #include #include #include...
  • xiang_6
  • xiang_6
  • 2017-10-11 16:56:37
  • 554

PTA 7-3 银行业务队列简单模拟

设某银行有A、B两个业务窗口,且处理业务的速度不一样,其中A窗口处理速度是B窗口的2倍 —— 即当A窗口每处理完2个顾客时,B窗口处理完1个顾客。给定到达银行的顾客序列,请按业务完成的顺序输出顾客序列...
  • hao_zong_yin
  • hao_zong_yin
  • 2017-10-25 00:34:39
  • 186


  • 2008年11月22日 15:08
  • 3KB
  • 下载
    访问量: 3万+
    积分: 4050
    排名: 9465