hdu3008_Warcraft

来源:互联网 发布:贷款那个软件好 编辑:程序博客网 时间:2024/06/05 08:35

Warcraft

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1673    Accepted Submission(s): 878


Problem Description
Have you ever played the Warcraft?It doesn't matter whether you have played it !We will give you such an experience.There are so many Heroes in it,but you could only choose one of them.Each Hero has his own skills.When such a Skill is used ,it costs some MagicValue,but hurts the Boss at the same time.Using the skills needs intellegence,one should hurt the enemy to the most when using certain MagicValue.

Now we send you to complete such a duty to kill the Boss(So cool~~).To simplify the problem:you can assume the LifeValue of the monster is 100, your LifeValue is 100,but you have also a 100 MagicValue!You can choose to use the ordinary Attack(which doesn't cost MagicValue),or a certain skill(in condition that you own this skill and the MagicValue you have at that time is no less than the skill costs),there is no free lunch so that you should pay certain MagicValue after you use one skill!But we are good enough to offer you a "ResumingCirclet"(with which you can resume the MagicValue each seconds),But you can't own more than 100 MagicValue and resuming MagicValue is always after you attack.The Boss is cruel , be careful!
 

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.
 

Output
Output an interger min (the minimun time you need to kill the Boss)in one line .But if you die(the LifeValue is no more than 0) ,output "My god"!
 

Sample Input
4 2 2510 520 1030 2876 704 2 2510 520 1030 2877 700 0 0
 

Sample Output
4My god
Hint
Hint: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!
 
题意:你有n种技能,每种技能都有它的消耗魔力的大小和伤害大小。每回合回复t个魔力值。问最少几回合可以打败魔王?
思路:类似背包,因为循环顺序的错误坑了ttond一小时。一开始我把skill放到了第一重循环,结果后来ttond给我讲了以后我才明白,原来skill的循环顺序就是打怪释放技能的顺序,但是释放技能的顺序与最终能不能得出答案是相关的。。。所以,把skill放到第三重循环就对了。。。切记。。
#include<bits/stdc++.h>#define INF 0xfffffffusing namespace std;int mag[105];int hurt[105];int dp[105][105];//!!time magicint main(){    int n,t,q;    while(scanf("%d%d%d",&n,&t,&q) && n+t+q){        int time = 100/q;        if(100%q)time++;        for(int i = 1; i <= n; i++)            scanf("%d%d",&mag[i],&hurt[i]);        mag[0] = 0;        hurt[0] = 1;        for(int i = 0; i <= time; i++)            for(int j = 0; j <= 100; j++)                dp[i][j] = -INF;        dp[0][100] = 0;        for(int j = 0; j < time; j++)//!!time            for(int k = 0; k <= 100; k++)//!!magic                for(int i = 0; i <= 1; i++){//!!skill                        if(k >= mag[i]){                            dp[j+1][min(100,k-mag[i]+t)] = max(dp[j][k]+hurt[i],dp[j+1][min(100,k-mag[i]+t)]);                        }                        dp[j+1][min(100,k+t)]=max(dp[j][k]+1,dp[j+1][min(100,k+t)]);                    }        int flag = 0;        for(int i = 1; i <= time; i++){            for(int j = 0; j <= 100; j++)            if(dp[i][j] >= 100){                printf("%d\n",i);                flag = 1;                goto loop;            }        }        loop:        if(!flag)printf("My god\n");        for(int i = 1; i <= time; i++){            for(int j = 0; j <= 100; j++)                if(dp[i][j] > 0)                    printf("%d %d %d\n",i,j,dp[i][j]);            }    }}


0 0
原创粉丝点击