编程介的小学生 2017-08-24 13:30 采纳率: 0.2%
浏览 745
已采纳

Doraemon's Battle

Doraemon is fighting with n enemies.

Doraemon has two properties in this battle, HP and SP. HP is the health point of Doraemon with initial value lh. If Doraemon's HP decreased to 0 or lower, Doraemon will lose the battle. SP is a property for using Doraemon's skill with initial value 0, which will be described later. HP has an upper bound lh (its initial value) and SP has an upper bound ls.

Doraemon and his enemies take turns to act. Doraemon acts before his enemies in each turn.

In each turn Doraemon can choose one of the following actions:

Kill one enemy and get his SP increased by 1.
Heal himself. Doraemon's HP will increase by floor(0.2*lh).
Use his skill if SP > 0. His skill will kill D[SP] enemies and reset his SP to 0. D is a sequence of integer which will be described in the input.
Do nothing.
Enemies will attack after Doraemon's action. Each enemy will cause one point damage to Doraemon. In the end of each turn, Doraemon get his SP increased by e mod 3 where e is the number of remaining enemies.

Now Doraemon wants to know the minimum number of turns he can kill all enemies.

Input

Input contains multiple cases, process to the end of input.

Each case contains two lines. The first line has three integers, lh (1 ≤ lh ≤ 250), ls (1 ≤ ls ≤ 100) and n. (1 ≤ n ≤ 40)

The following line describes sequence D mentioned in Doraemon's skill. The line contains ls integers, the ith integer refers to Di.

Output

For each case, output the minimum number of turns needed in a single line. If Doraemon will always lose the battle, print "HELP!" instead.

Sample Input

5 2 4
2 3
Sample Output

3

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-09-07 01:24
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化