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.
题意:题意是三国时期,吕布一人大战各路名将,首先给你6个数,分别是吕布的攻击值,防御值,生命值,升级后此三值各自的增量,然后是对手的个数num,接下来是各个对手的名字,攻击值,防御值,生命值,及经验值,规定当吕布经验值每提升100,则攻击值,防御值,生命值加上各自的增量。最后若吕布生命值大于0,输出生命值,否则输出一句话"Poor LvBu,his period was gone."。
思路:这道题的话,我们首先需要定义一个结构体,然后定义三个数组,然后因为这道题有许多的状态,所以我们要用状压DP来做。所以之前定义的LvBu[i]表示i对应的二进制中1表示已经与此人对战。然后就是我们通过for循环来判断先与谁进行挑战。然后剩下的就是基本的判断了。
AC代码:
#include <bits/stdc++.h>
typedef long long ll;
const int maxx=10010;
const int inf=0x3f3f3f3f;
using namespace std;
struct node
{
int attck;
int defense;
int hp;
int expirence;
} LvBu[1<<25],Enemy[25],Update;
char name[25];
int result,n;
void fight()
{
int attck,defence;
int myTime,Time;
int rHp,expirence,rattack,rdef;
for(int i=0; i<=result; i++)
for(int j=0; j<n; j++)
{
if(!(i&(1<<j)) && LvBu[i].hp>0)
{
attck=max(1,LvBu[i].attck-Enemy[j].defense);
defence=max(1,Enemy[j].attck-LvBu[i].defense);
myTime=(LvBu[i].hp+defence-1)/defence;
Time=(Enemy[j].hp+attck-1)/attck;
if(myTime<Time)
continue;
rHp=(LvBu[i].hp-(Time-1)*defence);
expirence=Enemy[j].expirence+LvBu[i].expirence;
rattack=LvBu[i].attck;
rdef=LvBu[i].defense;
if(expirence>=100)
{
expirence-=100;
rattack+=Update.attck;
rdef+=Update.defense;
rHp+=Update.hp;
}
if(rHp>=LvBu[i|(1<<j)].hp)
{
LvBu[i|(1<<j)].attck=rattack;
LvBu[i|(1<<j)].defense=rdef;
LvBu[i|(1<<j)].hp=rHp;
LvBu[i|(1<<j)].expirence=expirence;
}
}
}
if(LvBu[result].hp)
printf("%d\n",LvBu[result].hp);
else
printf("Poor LvBu,his period was gone.\n");
}
int main()
{
while(scanf("%d%d%d%d%d%d",&LvBu[0].attck,&LvBu[0].defense,&LvBu[0].hp,&Update.attck,&Update.defense,&Update.hp)!=EOF)
{
LvBu[0].expirence=0;
scanf("%d",&n);
for(int i=0; i<n; i++)
scanf("%s%d%d%d%d",name,&Enemy[i].attck,&Enemy[i].defense,&Enemy[i].hp,&Enemy[i].expirence);
result=(1<<n)-1;
for(int i=1; i<=result; i++)
LvBu[i].hp=0;
fight();
}
return 0;
}