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

10 6 100
17 5

Output

4
STRIKE
HEAL
STRIKE
STRIKE

Input

11 6 100
12 5

Output

2
STRIKE
STRIKE

题意:vova要打败一个怪物,vova 的血量h1,攻击力a1,可以无限使用的血瓶c1,可以加c1这么多血,加的血量可以无上限。怪物的血量h2,攻击力a2。

思路:模拟就行。【注意】一开始没考虑,可以一击必杀的那种情况,就是h2怪物血量小于,vova攻击力并且vova血量小于怪物攻击力,其实不用加血的,直接秒杀

AC代码:

 1 #include<bits/stdc++.h>
 2
 3 using namespace std;
 4
 5 #define int long long
 6 int arr[100500];
 7 signed  main(){
 8     int h1,a1,c1;
 9     int h2,a2;
10     cin>>h1>>a1>>c1;
11     cin>>h2>>a2;
12     if(a1>=h2){
13         printf("1\nSTRIKE");
14         return 0;
15     }
16     int x1=0;
17     int x2=0;
18     if(h2%a1){
19         x1++;
20     }
21     if(h1%a2){
22         x2++;
23     }
24     x1+=h2/a1;
25     x2+=h1/a2;
26     if(x2>=x1){
27         printf("%d\n",x1);
28         for(int i=0;i<x1;i++){
29             printf("STRIKE\n");
30         }
31         return 0;
32     }
33     int cnt=1;
34     while(1){
35         if((h2-a1<=0)){// 【注意】:可以一击必杀的QAQ
36             arr[cnt++]=1;
37             break;
38         }
39         if((h1-a2)<=0){
40             arr[cnt++]=0;
41             h1+=c1;
42         }else{
43             h2=h2-a1;
44             arr[cnt++]=1;
45             if(h2<=0){
46                 break;
47             }
48
49         }
50         h1-=a2;
51     }
52     printf("%d\n",cnt-1);
53     for(int i=1;i<cnt;i++){
54         if(arr[i]==1){
55             printf("STRIKE\n");
56         }else{
57             printf("HEAL\n");
58         }
59     }
60     return 0;
61 }

原文地址:https://www.cnblogs.com/pengge666/p/11552476.html

时间: 2024-11-06 03:41:36

Educational Codeforces Round 34 (Rated for Div. 2) B题【打怪模拟】的相关文章

Educational Codeforces Round 74 (Rated for Div. 2)补题

慢慢来. 题目册 题目 A B C D E F G 状态 √ √ √ √ × ? ? //√,×,? 想法 A. Prime Subtraction res tp A 题意:给定\(x,y(x>y)\),问能否将\(x-y\)拆成任意多个质数之和 1.任意大于\(1\)的整数\(k\)都可以用\(2\)与\(3\)的线性表示 证: 若\(k\)是偶数,显然: 若\(k\)是奇数,则\(k\)可以表示成\(k = 3 + 2*k'\),显然: 毕. #include<bits/stdc++.h&

Educational Codeforces Round 34 (Rated for Div. 2) D. Almost Difference[数据结构]

题意:求一个数列中所有的绝对值差大于2的数,并用后面的数字减前面的数字的加和. 分析:可以用树状数组每次找前面的差值大于2的数,也可以直接每次加前面所有的数字,再减去差值为1的数字.题目最坑爹的是答案也许会爆long long,可以用long double或者使用unsigned long long手动模拟符号位,或者用python C++代码: 1 #define _CRT_SECURE_NO_DEPRECATE 2 #pragma comment(linker, "/STACK:102400

Educational Codeforces Round 34 (Rated for Div. 2) ABC

A. Hungry Student Problem Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken. CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large o

codeforces Educational Codeforces Round 55 (Rated for Div. 2) C题 C. Multi-Subject Competition

这道题比赛时候没做出来,下来一看才发现是排序傻逼题. 把每个偏好的人做成一个vector,从大到小排序,做一个前缀和.然后将每种人数做一个桶,在桶里装每种科目选择人数为i的时候分数总和. 遍历每一维vector,把各个位置上面的vector加到sum数组中,最后sum数组里面挑出最大值. #include<bits/stdc++.h> using namespace std; typedef long long ll; vector<int> vec[100010];//vecto

Educational Codeforces Round 63 (Rated for Div. 2) B题

题目网址:https://codeforc.es/contest/1155/problem/B 题目大意:有两个人A,B博弈,在一串数字中,A先取数,B后取数,最后剩11个数的时候停止,如果第一个数是8,则A胜,反之B胜 题解:取数到最后,只剩11个数,且,A如果要赢,第一个数是8,则A显然是要尽可能的先取前面的非8数,B要先去前面的8,按照这样的策略,只需考虑前面n -10个数取到最后是否有8即可,显然是判断8的数量和其他数的数量的大小即可. 1 #include<bits/stdc++.h>

Educational Codeforces Round 63 (Rated for Div. 2) D题

题目网址:https://codeforc.es/contest/1155/problem/D 题目大意:给定n个数和一个k,可以对这n个数进行一次操作,也可以不进行,即选择某个区间中的数都乘上k,问最后最大连续子段和是多少? 题解:(鶸鶸的我是看别人的博客才解决的 ! ) 首先这道题的状态很多,对于前m个数,乘k之前的状态,乘k的状态,之和的状态都需要建立.那么分别设dp1,dp2,dp3是乘k之前,乘k时,乘k之和,前m个数最大连续子段和. 首先对于dp1,即一组数的最大子段和,显然只要是正

Educational Codeforces Round 33 (Rated for Div. 2) A题

A. Chess For Three Alex, Bob and Carl will soon participate in a team chess tournament. Since they are all in the same team, they have decided to practise really hard before the tournament. But it's a bit difficult for them because chess is a game fo

Educational Codeforces Round 33 (Rated for Div. 2) B题

B. Beautiful Divisors Recently Luba learned about a special kind of numbers that she calls beautiful numbers. The number is called beautiful iff its binary representation consists of k + 1 consecutive ones, and then k consecutive zeroes. Some example

Educational Codeforces Round 33 (Rated for Div. 2) C题&#183;(并查集变式)

C. Rumor Vova promised himself that he would never play computer games... But recently Firestorm — a well-known game developing company — published their newest game, World of Farcraft, and it became really popular. Of course, Vova started playing it