题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3008
Input
There are several test cases,intergers n ,t and q (0<n<=100,1<=t<=5,q>0) in the first line which mean you own n kinds of skills ,and the "ResumingCirclet" helps you resume t points of MagicValue per second and q is of course the hurt points of LifeValue the Boss attack you each time(we assume when fighting in a second the attack you show is before the Boss).Then n lines follow,each has 2 intergers ai and bi(0<ai,bi<=100).which means using i skill costs you ai MagicValue and costs the Boss bi LifeValue.The last case is n=t=q=0.
有n个技能,每秒回蓝t值,boss每次攻击能造成q点伤害,n行,每行ai,bi,表示第i个消耗ai的魔法值,造成bi的伤害。看谁先死,boss死了输出第几次攻击死的,否则输出
“My god”
注意:
这个游戏不会回血。
每回合英雄先攻击,回合结束才加蓝,可以选择不用技能攻击,消耗0魔法值,扣boss一滴血。
可以由这次的攻击推导下一次攻击
dp[i][j]存储第i个回合j魔法值时最大的攻击力(已经攻击boss,没有回蓝)
#include <stdio.h>
#include <string.h>
int dp[120][120];
int num[120];
int hurt[120];
int max(int a,int b)
{
if(a > b)
return a;
return b;
}
int main()
{
int n,t,q,times;
int i,j,k,tmp;
int flag;
while(~scanf("%d %d %d",&n,&t,&q),n&&t&&q)
{
memset(dp,0,sizeof(dp));
times = 100/q;
if(100%q != 0)
times++;//最多有几个回合,即几次攻击
for(i = 1; i <= n; i++)
{
scanf("%d %d",&num[i],&hurt[i]);
if(100+t-num[i] >100)
tmp = 100;
else tmp = 100+t-num[i];
dp[1][tmp] = max(dp[1][tmp],hurt[i]);
}
for(i = 1; i <= times; i++)
{
for(j = 0; j <= 100; j++)
{
for(k = 1; k <= n; k++)
{
if(j-num[k] >= 0)
dp[i+1][j-num[k]+t] = max(dp[i+1][j-num[k]+t],dp[i][j]+hurt[k]);//
else dp[i+1][j+t] = max(dp[i+1][j+t],dp[i][j]+1);//不用技能
}
}
}
//寻找有没有攻击力大于100的
flag = 0;
for(i = 1; i <= times; i++)
{
if(!flag)
{
for(j = 0; j <= 100; j++)
{
if(dp[i][j] >= 100)
{
flag = 1;
tmp = i;
break;
}
}
}
else break;
}
if(flag)
printf("%d\n",tmp);
else printf("My god\n");
}
return 0;
}