题意 你去打boss 开始你的蓝和血还有boss的血都是100 每秒你先打boss一下 然后boss打你一下你减少q点血 你有n个技能 第i个技能耗蓝a[i] 对boss的伤害为b[i] 普攻伤害为1 而且你每秒回复t点蓝(恢复后不超过100) 求你最少可以多少次打死boss
你最多能打100/q或者100/q+1次 令d[i][j]表示第i秒所剩蓝量为j时boss剩下的最少血量 m为j还未恢复蓝之前的蓝量 j = min (100, m + t) 那么有 d[i][j] = min (d[i][j], d[i - 1][m + a[k]] - b[k]);
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 105;
int a[N], b[N], d[N][N];
int main()
{
int n, t, q, ans, ti;
while (scanf ("%d%d%d", &n, &t, &q), n)
{
++n;
ti = (100 % q) ? (100 / q + 1) : (100 / q);
a[1] = 0, b[1] = 1;
for (int i = 2; i <= n; ++i)
scanf ("%d%d", &a[i], &b[i]);
memset (d, 0x3f, sizeof (d));
d[0][100] = 100; ans = 0;
for (int i = 1; i <= ti; ++i)
for (int m = 0; m <= 100; ++m)
{
int j = min (100, m + t);
for (int k = 1; k <= n; ++k)
if (m + a[k] <= 100)
d[i][j] = min (d[i][j], d[i - 1][m + a[k]] - b[k]);
if (d[i][j] <= 0)
{
ans = i, i = ti;
break;
}
}
if (ans == 0) printf ("My god\n");
else printf ("%d\n", ans);
}
return 0;
}
4 2 25 10 5 20 10 30 28 76 70 4 2 25 10 5 20 10 30 28 77 70 0 0 0
4 My godHintHint: When fighting,you can only choose one kind of skill or just to use the ordinary attack in the whole second,the ordinary attack costs the Boss 1 points of LifeValue,the Boss can only use ordinary attack which costs a whole second at a time.Good Luck To You!
HDU 3008 Warcraft (DP),布布扣,bubuko.com
原文地址:http://blog.csdn.net/iooden/article/details/38661685