B-The Modcrab
2018-01-18 21:09
134 查看
B. The Modcrabtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVova 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.InputThe 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.OutputIn 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.Examplesinput
解题思路:虽然题很长,但是很好理解,就是先计算出杀死怪兽用到几步,然后再考虑自己的健康值h1够不够这几步用的,如果够的话直接输出n个STRIKE,否则的话就需要补充血量,这里需要特别注意的是,每次补充血量的时候,还是会受到怪物的攻击,而且不会攻击怪物,所以实际补充的血量只有c1-a2.
ac代码:
不懂得欢迎私聊嗷~ 么么哒(*  ̄3)(ε ̄ *)
10 6 100 17 5output
4 STRIKE HEAL STRIKE STRIKEinput
11 6 100 12 5output
2 STRIKE STRIKENoteIn 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.
解题思路:虽然题很长,但是很好理解,就是先计算出杀死怪兽用到几步,然后再考虑自己的健康值h1够不够这几步用的,如果够的话直接输出n个STRIKE,否则的话就需要补充血量,这里需要特别注意的是,每次补充血量的时候,还是会受到怪物的攻击,而且不会攻击怪物,所以实际补充的血量只有c1-a2.
ac代码:
#include<stdio.h> #include<string.h> int main() {{ int h1, a1, c1; int h2, a2; int vis[1000]; int t = 0; scanf("%d%d%d", &h1, &a1, &c1); scanf("%d%d", &h2, &a2); memset(vis, 0, sizeof(vis)); int n = h2 / a1; if (h2%a1 != 0) n = n + 1; if (h1 > (n-1)*a2) { printf("%d\n", n); for (int i = 0; i < n; i++) { printf("STRIKE\n"); } } else if (h1 <= (n-1)*a2) { int n3,n4; int n2 = ((n-1)*a2 - h1 + 1) % (c1-a2); if (n2 == 0) n3 = n + ((n - 1)*a2 - h1 + 1) / (c1-a2); else if (n2 != 0) n3 = n + ((n-1)*a2 - h1 + 1) / (c1-a2) + 1; n4 = n3 - n; printf("%d\n", n3); for (int i = 1; i <= n3; i++) { if (i<=n4) printf("HEAL\n"); else if (i>n4) printf("STRIKE\n"); } } return 0; }}
不懂得欢迎私聊嗷~ 么么哒(*  ̄3)(ε ̄ *)
相关文章推荐
- 903B - The Modcrab
- Codeforces 903B - The Modcrab 模拟+记录
- The Modcrab_Codeforces
- Educational Codeforces Round 34 (Rated for Div. 2)B. The Modcrab(贪心)
- G - The Modcrab
- 【Codeforces 903B】The Modcrab
- cf 903B - The Modcrab
- Mod_python: The Long Story
- 【PowerDesigner】:Generation aborted due to errors detected during the verification of the mod
- Configure the modules to be find by modprobe
- Apress.The.Definitive.Guide.to.Apache.mod.rewrite.Feb.2006.eBook
- compile the mod_gsoap of apache2 for win32
- proxy: No protocol handler was valid for the URL /. If you are using a DSO version of mod_proxy, make sure the proxy sub
- ModSecurity Advanced Topic of the Week: Detecting Malware with Fuzzy Hashing
- 0001: unable to locate the content swf directory: app:/mod/win
- Beatmod feat.Yoshi Honeycomb what's is the the new RamHacked SPL/Radio
- The mod(%) operation 负数取模运算详解
- Uncaught Error: [$injector:nomod] Module 'xxx' is not available! You either misspelled the m
- OllyICE TheMida MOD By EvOlUtIoN
- The Definitive Guide to Apache mod_rewrite