博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Educational Codeforces Round 34 B. The Modcrab【模拟/STL】
阅读量:5063 次
发布时间:2019-06-12

本文共 3685 字,大约阅读时间需要 12 分钟。

B. The Modcrab
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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 bya1) 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.

【分析】:STL还是用的太少了···C++还要再学一波

【代码】:

#include 
using namespace std;#define ll long long#define oo 10000000const int mod = 1e6;int main(){ vector
v; int a1,b1,h1; int a2,b2; int j=0; int f[500]; scanf("%d%d%d",&a1,&b1,&h1); scanf("%d%d",&a2,&b2); while(1) { if(b1>=a2) //一击必杀就跳出···因为怪兽你已经死了 { v.push_back("STRIKE"); break; } else { if(a1<=b2) { a1 += h1; //补血 a1 -= b2; //补完还是要被打 怪兽不会等你补就不打了 v.push_back("HEAL"); } else { a1 -= b2; //我的血少了 a2 -= b1; //怪兽的血少了 v.push_back("STRIKE"); } } } printf("%d\n",(int)v.size()); for(auto &i:v) { printf("%s\n",i.c_str()); } return 0;}
View Code

 

转载于:https://www.cnblogs.com/Roni-i/p/8030628.html

你可能感兴趣的文章
SQL Server 使用作业设置定时任务之一(转载)
查看>>
第二阶段冲刺-01
查看>>
BZOJ1045 HAOI2008 糖果传递
查看>>
发送请求时params和data的区别
查看>>
JavaScript 克隆数组
查看>>
eggs
查看>>
一步步学习微软InfoPath2010和SP2010--第七章节--从SP列表和业务数据连接接收数据(4)--外部项目选取器和业务数据连接...
查看>>
如何增强你的SharePoint 团队网站首页
查看>>
FZU 1914 Funny Positive Sequence(线性算法)
查看>>
oracle 报错ORA-12514: TNS:listener does not currently know of service requested in connec
查看>>
基于grunt构建的前端集成开发环境
查看>>
MySQL服务读取参数文件my.cnf的规律研究探索
查看>>
java string(转)
查看>>
__all__有趣的属性
查看>>
写博客
查看>>
利用循环播放dataurl的视频来防止锁屏:NoSleep.js
查看>>
python3 生成器与迭代器
查看>>
java编写提升性能的代码
查看>>
ios封装静态库技巧两则
查看>>
Educational Codeforces Round 46 (Rated for Div. 2)
查看>>