HDU - 2809 God of War (暴力状压dp)(模拟)

在公元184~280年的中国,存在着多个王国,其中最强的是魏、蜀、吴三国。吕布,被誉为战神,智勇双全但野心勃勃。面对众多敌人,尤其是曹操麾下的诸多将领,吕布如何利用自己的战斗技能和经验值战胜所有敌人并存活下来?本文通过分析吕布的攻击力、防御力、生命值以及敌人的属性,探讨了吕布在三国时期生存和胜利的可能性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

At 184~280 A.D ,there were many kingdoms in China. Three strongest among them are “Wei”, “Shu”, “Wu”. People call this period as “Three Kingdoms”.
HH is a super “Three Kingdoms” fan, because at this period there were many heroes and exciting stories. Among the heroes HH worships LvBu most.
LvBu is the God of War and is also intelligent, but his ambition is too big while enemies are too powerful .Many monarchs wanted to kill him.
At 198 A.D ,CaoCao fought with LvBu at Xuzhou.Though Lvbu is the God of War ,CaoCao had so many generals: Xuchu,DianWei XiahouChun……Facing so many heroes ,could LvBu beat all of them?

Given the LvBu’s ATI, DEF, HP, and enemies’ ATI, DEF,HP, experience (if LvBu killed one of his enemies, he can get that experience ,and if his experience got more than or equal to 100*level,he would level-up and become stronger) and the In_ATI,In_DEF,In_HP(indicating when LvBu levels up,his ability will increase this point).
Each turn LvBu will choose an enemy to fight. Please help LvBu find a way to beat all of enemies and survive with the max HP.
Here’s a fight between LvBu and A:
If LvBu attack A, A will lose Max(1,LvBu’s ATI- A’s DEF) hp;
If A survived, he will give LvBu Max(1,A’ATI- LvBu’DEF) injury.
If LvBu is still alive, repeat it untill someone is dead(hp <= 0).
LvBu’s initial level is 1 and experience is 0,and he can level up many times.
Input
The input contains at most 20 test cases.
For each case , the first line contains six intergers ,indicating LvBu’s ATI,DEF,HP and In_ATI,In_DEF,In_HP.
The next line gives an interger N(0<N<=20),indicating the number of the enemies .
Then N lines followed, every line contains the name(the length of each name is no more than 20),ATI,DEF,HP, experience(1<experience<=100).
Output
If LvBu is dead output “Poor LvBu,his period was gone.”
Or output the maximum HP left.
Sample Input
100 80 100 5 5 5
2
ZhangFei 95 75 100 100
XuChu 90 90 100 90

100 75 100 5 5 5
1
GuanYu 95 85 100 100
Sample Output
30
Poor LvBu,his period was gone.

太暴力了
不到20,所以每一次选取一个状态,枚举和所有对手交战的情况


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<math.h>
using namespace std;
typedef long long ll;
int A[30],D[30],H[30],E[30];
int ati,def,hp,inati,indef,inhp;
int dp[1<<20];
char tem[300];

int main(){
	while(~scanf("%d%d%d%d%d%d",&ati,&def,&hp,&inati,&indef,&inhp)){
		int n;
		scanf("%d",&n);
		for(int i=0;i<=n-1;i++){
			scanf("%s%d%d%d%d",tem,&A[i],&D[i],&H[i],&E[i]);
		}
		memset(dp,0,sizeof(dp));
		dp[0]=hp;
		for(int i=0;i<(1<<n);i++){
			if(dp[0]<=0) continue;
			int eps=0;
			for(int j=0;j<=n-1;j++)
				if(i&(1<<j))
					 eps+=E[j];
			int nowlev=eps/100;
			int nowati=ati+nowlev*inati;
			int nowdef=def+nowlev*indef;
			nowlev++;				
			for(int j=0;j<=n-1;j++){
				if((i&(1<<j))==0){
				int cnt=H[j]/(max(nowati-D[j],1))-1;
				if(H[j]%(max(nowati-D[j],1))) cnt++;
				int nowhp=dp[i]-cnt*(max(A[j]-nowdef,1));
				if(nowhp<=0) continue;
				if(eps+E[j]>=100*nowlev) nowhp+=inhp;
				int st=i+(1<<j);
				if(nowhp>dp[st]) dp[st]=nowhp;
				}
			}
		}
	//	for(int i=1;i<(1<<n);i++) printf("i:%d %d\n",i,dp[i]);
		if(dp[(1<<n)-1]<=0) printf("Poor LvBu,his period was gone.\n");
		else printf("%d\n",dp[(1<<n)-1]);
	}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值