The Modcrab

6人阅读 评论(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 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
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.

Vova再次玩一些电脑游戏,现在一个RPG。在游戏中Vova的角色接受任务:杀死怪物叫Modcrab。经过两个小时的玩游戏,Vova已找到怪物并分析其策略。Modcrab H2健康点和A2的攻击力。要知道,Vova已经决定买很多强大的治疗药水和准备战斗。Vova的性格中有H1健康点和A1的攻击力。他也有大量的治疗药剂,分别增加电流量健康点C1当Vova喝药水。所有药水都是一样的。这是保证C1 > A2。战斗由多个阶段组成。在每一个阶段的开始,Vova可以攻击怪物(A1从而降低其健康)或喝药水(增加Vova的健康由C1;Vova的健康可以超过H1)。然后,如果战斗还没有结束,这modcrab攻击Vova,A2减少他的健康。战争结束时,Vova(或Modcrab)健康下降到0或更低。这是可能的,战斗结束在中间的一个阶段,Vova的攻击后。
当然,Vova想要赢得这场战斗。但他也希望尽可能快地完成它。所以他想制定一个策略,让他在尽可能少的几个阶段赢得战斗。
帮助Vova制定策略!你可能会认为Vova从来没有用完的治疗药剂,而他总是能赢。


思路:

如果下次决斗不能被怪兽打死就可以不喝药水~~·,如果能被打死就得先喝药水

代码:
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 10005;
int arr[N];
int main(){
	int h1,a1,c1;
	int h2,a2;
	cin>>h1>>a1>>c1;
	cin>>h2>>a2;
    int cnt=0;
    while(h2>0){
    	if(h1<=a2&&a1<h2){
    		arr[cnt++]=1;
    		h1+=c1;
    		h1-=a2;
		}
		else{
			arr[cnt++]=2;
			h2-=a1;
			h1-=a2;
		}
	}
	cout<<cnt<<endl;
	for(int i=0;i<cnt;i++){
		if(arr[i]==1) cout<<"HEAL"<<endl;
		else if(arr[i]==2) cout<<"STRIKE"<<endl;
	}
	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(模拟)

题意:一个人在打怪,他每回合可以选择喝药加血或者打怪,然后怪物会攻击他一次,让你输出一个他可以打死怪物的方案(任意一个即可,特殊判定),但是注意他的血量可以无上限。第一行输入他的当前血量h1,攻击力a...
  • ZscDst
  • ZscDst
  • 2017-12-20 20:06:39
  • 193

The Modcrab_Codeforces

原题链接:http://codeforces.com/contest/903/problem/B B. The Modcrab time limit per test 1 sec...
  • qq_34622474
  • qq_34622474
  • 2017-12-13 22:49:08
  • 139

The Modcrab (简单模拟)

The ModcrabVova is again playing some computer game, now an RPG. In the game Vova's character receiv...
  • codeswarrior
  • codeswarrior
  • 2018-04-17 16:48:18
  • 21

B-The Modcrab

B. The Modcrabtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutput...
  • qq_40129237
  • qq_40129237
  • 2018-01-18 21:09:22
  • 39

903B - The Modcrab

B. The Modcrab time limit per test 1 second memory limit per test 256 megabytes input standard...
  • memory_qianxiao
  • memory_qianxiao
  • 2017-12-13 22:02:38
  • 130

G - The Modcrab

Vova is again playing some computer game, now an RPG. In the game Vova's character received a quest:...
  • Abandoninged
  • Abandoninged
  • 2018-01-07 09:56:11
  • 62

cf 903B - The Modcrab

B. The Modcrab time limit per test 1 second memory limit per test 256 megabytes input standard...
  • Haipai1998
  • Haipai1998
  • 2018-02-02 14:42:45
  • 37
    人生哲言
    当能力不足以支持野心时,静下来敲敲代码。
    个人资料
    持之以恒
    等级:
    访问量: 2万+
    积分: 4317
    排名: 8988
    博客专栏
    最新评论