Educational Codeforces Round 34 (Rated for Div. 2) B题【打怪模拟】
B. 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.
Input
Output
STRIKE
HEAL
STRIKE
STRIKE
Input
Output
STRIKE
STRIKE
题意:vova要打败一个怪物,vova 的血量h1,攻击力a1,可以无限使用的血瓶c1,可以加c1这么多血,加的血量可以无上限。怪物的血量h2,攻击力a2。
思路:模拟就行。【注意】一开始没考虑,可以一击必杀的那种情况,就是h2怪物血量小于,vova攻击力并且vova血量小于怪物攻击力,其实不用加血的,直接秒杀
AC代码:
#include<bits/stdc++.h> using namespace std; #define int long long
int arr[];
signed main(){
int h1,a1,c1;
int h2,a2;
cin>>h1>>a1>>c1;
cin>>h2>>a2;
if(a1>=h2){
printf("1\nSTRIKE");
return ;
}
int x1=;
int x2=;
if(h2%a1){
x1++;
}
if(h1%a2){
x2++;
}
x1+=h2/a1;
x2+=h1/a2;
if(x2>=x1){
printf("%d\n",x1);
for(int i=;i<x1;i++){
printf("STRIKE\n");
}
return ;
}
int cnt=;
while(){
if((h2-a1<=)){// 【注意】:可以一击必杀的QAQ
arr[cnt++]=;
break;
}
if((h1-a2)<=){
arr[cnt++]=;
h1+=c1;
}else{
h2=h2-a1;
arr[cnt++]=;
if(h2<=){
break;
} }
h1-=a2;
}
printf("%d\n",cnt-);
for(int i=;i<cnt;i++){
if(arr[i]==){
printf("STRIKE\n");
}else{
printf("HEAL\n");
}
}
return ;
}
Educational Codeforces Round 34 (Rated for Div. 2) B题【打怪模拟】的更多相关文章
- Educational Codeforces Round 34 (Rated for Div. 2) A B C D
Educational Codeforces Round 34 (Rated for Div. 2) A Hungry Student Problem 题目链接: http://codeforces. ...
- Educational Codeforces Round 34 (Rated for Div. 2) D - Almost Difference(高精度)
D. Almost Difference Let's denote a function You are given an array a consisting of n integers. You ...
- Educational Codeforces Round 34 (Rated for Div. 2) C. Boxes Packing
C. Boxes Packing time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- Educational Codeforces Round 34 (Rated for Div. 2)
A. Hungry Student Problem time limit per test 1 second memory limit per test 256 megabytes input sta ...
- Educational Codeforces Round 78 (Rated for Div. 2) --补题
链接 直接用数组记录每个字母的个数即可 #include<bits/stdc++.h> using namespace std; int a[26] = {0}; int b[26] = ...
- Educational Codeforces Round 76 (Rated for Div. 2) D题
题意: 给你n个关卡,每个关卡有一个怪物,怪物的攻击力为a[i],你有n个英雄,每个英雄有一个攻击力,和疲劳值,只要英雄的攻击力比怪物的高就算打过了,同时疲劳减一,一天只能出战一个英雄,一个英雄可以打 ...
- Educational Codeforces Round 67 (Rated for Div. 2) B题【前缀+二分】【补题ING系列】
题意:给出一个字符串s, 可以从左往右拿走s的字符, 至少要到s的第几个位置才能拼成t 思路:用二维数组记录前缀,然后二分即可. #include<bits/stdc++.h> using ...
- Educational Codeforces Round 72 (Rated for Div. 2) C题
C. The Number Of Good Substrings Problem Description: You are given a binary string s (recall that a ...
- Educational Codeforces Round 72 (Rated for Div. 2) B题
Problem Description: You are fighting with Zmei Gorynich — a ferocious monster from Slavic myths, a ...
随机推荐
- 小记------phoenix安装搭建
1.下载与hbase对应版本的phoenix http://phoenix.apache.org/download.html 2.解压 tar -zxvf apache-pho ...
- Thinking In Java 4th Chap5 初始化和清理
类的构造器名必须与类名一致,且无返回类型,通过参数类型的不同(即使顺序不同也行)可以重载构造器,也可以以此技巧重载方法 this关键字:表示对“调用方法的那个对象的引用”,也可将当前对象传递给其他方法 ...
- python学习-4 python基础-2 条件语句(if的简单用法1)
条件语句的原理: 2.举个例子:比大小 #!/usr/bin/env python # -*- coding:utf8 -*- a=input("请输入a:") b=input(& ...
- Memcache与Redis有什么区别?
Redis 和 Memcache 都是基于内存的数据存储系统.Memcached是高性能分布式内存缓存服务,其本质上就是一个内存key-value数据库.Redis是一个开源的key-value存储系 ...
- Spring Boot(一) 初步理解Spring Boot
一.Spring Boot所解决的问题 Java开发十分笨重:繁多的配置.低下的开发效率.复杂的部署流程以头疼的第三方技术集成. Spring Boot的理念:习惯优于配置——项目中存在大量的配置,此 ...
- 利用element-ui封装地址输入的组件
我们前端做项目时,难免会遇到地址输入,多数情况下,我们都是提供一个省市三级联动,加上具体地址输入的Input输入框给用户,用以获取用户需要输入的真实地址.在需要对用户输入的数据进行校验的时候,我们会单 ...
- SQL将多行数据合并成一行【转】
转:https://blog.csdn.net/AntherFantacy/article/details/83824182 今天同事问了一个需求,就是将多行数据合并成一行进行显示,查询了一些资料,照 ...
- vue.js devtools图标不亮
第一步:打开谷歌扩展程序 第二步:设置允许访问文件地址
- Node.js学习(3)-用express改写留言本
安装 cnpm i -S express cnpm i -S express-art-template cnpm i -S art-template var express = require(' ...
- HTTP中GET,POST和PUT的区别
一.HTTP中定义了以下几种请求方法: 1.GET:2.POST:3.PUT:4.DELETE;5.HEAD:6.TRACE:7.OPTIONS: 二.各个方法介绍: 1.GET方法:对这个资源的查操 ...