Question: lub vs. qunxiong, each hero has his own attack power, defensive power, and hp (blood volume). lub is quite special. When he has accumulated experience of 100, he can upgrade .. Add attributes when upgrading.
It is fair to say that each hero takes turns to fight Lu Bu. When Lu Bu kills a hero, he can gain experience and ask whether Lu Bu can kill all the heroes, if possible, find
The maximum remaining blood volume.
Analysis: How has this question been assigned to a Search topic? Ah, how to pruning or timeout ......
It is indeed a bare state compressed DP, And the status is transferred from the bottom up
#include<iostream>#include<algorithm>using namespace std;struct hero{int att,def,hp,lev;int exp;}dp[(1<<20)+1];struct enemy{int att,def,hp,exp;};enemy e[25];int att,def,hp;void init(){for(int i=1;i<(1<<20)+1;i++)dp[i].hp=0;}int main(){char str[25];while(scanf("%d %d %d %d %d %d",&dp[0].att,&dp[0].def,&dp[0].hp,&att,&def,&hp)==6){int n=0;scanf("%d",&n);for(int i=0;i<n;i++)scanf("%s %d %d %d %d",str,&e[i].att,&e[i].def,&e[i].hp,&e[i].exp);init();dp[0].lev=1;dp[0].exp=0;for(int j=0;j<(1<<n)-1;j++){if(dp[j].hp<=0)continue;for(int k=0;k<n;k++){hero temp=dp[j];if((j&(1<<k))!=0)continue;int sub=max(temp.att-e[k].def,1); int sub1=max(e[k].att-temp.def,1);int time=(e[k].hp/sub)+((e[k].hp%sub==0)?-1:0);temp.hp-=time*sub1;if(temp.hp<=0)continue;temp.exp+=e[k].exp;if(temp.exp>=temp.lev*100){temp.lev++;temp.att+=att;temp.def+=def;temp.hp+=hp;}if(temp.hp>dp[j|(1<<k)].hp)dp[j|(1<<k)]=temp;}}if(dp[(1<<n)-1].hp<=0){puts("Poor LvBu,his period was gone.");continue;}printf("%d\n",dp[(1<<n)-1].hp);}return 0;}