God of War

Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1671    Accepted Submission(s): 647

 

Problem Description

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


ZhangFei
XuChu GuanYu
 

Sample Output

Poor LvBu,his period was gone.

题目大意

吕布去打架,有n个对手,告诉你吕布初始攻击力 防御力 生命值 还有每次升级对于三项属性的增加量 以及n个对手的三项属性 和击败他们所能获得的经验值 每次经验值过100就会升级

每次战斗时,都是吕布先出手,双方造成的伤害是攻击力减防御力。

问吕布能否将对手全部击败,如果能就输出最后的最大生命值,否则输出"Poor LvBu,his period was gone."

题目分析

状压DP,用二进制代表当前已经击败的敌人,dp[i]代表达到当前状态所能维持的最大血量,每次看这个敌人有没有攻击,没有攻击就和他打,打完看能不能更新dp数组即可。

#include<bits/stdc++.h>

using namespace std;

struct
{
int ati;
int def;
int hp;
int exp;
}lvbu[<<],a[]; int inati,indef,inhp,n,i,N,j,nati,ndef,nhp,nexp,att,lose,attime,deftime;
string str; int main()
{
while(scanf("%d%d%d%d%d%d",&lvbu[].ati,&lvbu[].def,&lvbu[].hp,&inati,&indef,&inhp)!=EOF)
{
lvbu[].exp=;
cin>>n;
for(i=;i<n;i++)
{
cin>>str>>a[i].ati>>a[i].def>>a[i].hp>>a[i].exp;
}
N=(<<n)-; //这个地方一定不要写成 1<<n-1 会被解释成 1<<(n-1)的!!!
for(i=;i<=N;i++)
{
lvbu[i].hp=;
}
for(i=;i<=N;i++)
{
for(j=;j<n;j++)
{
if(lvbu[i].hp>&&(!(i&(<<j)))) //当前状态还有血并且没有和第j个敌人交战
{
att=max(,lvbu[i].ati-a[j].def); //吕布一刀砍多少
lose=max(,a[j].ati-lvbu[i].def); //敌人一刀砍多少
attime=(a[j].hp+att-)/att; //打死敌人需要的次数 向上取整
deftime=(lvbu[i].hp+lose-)/lose; //敌人打死吕布需要的次数
if(attime>deftime)
continue;
nhp=lvbu[i].hp-lose*(attime-);
nexp=lvbu[i].exp+a[j].exp;
ndef=lvbu[i].def;
nati=lvbu[i].ati;
if(nexp>=)
{
nhp+=inhp;
ndef+=indef;
nati+=inati;
nexp-=;
}
if(lvbu[i|<<j].hp<=nhp)
{
lvbu[i|<<j].hp=nhp;
lvbu[i|<<j].def=ndef;
lvbu[i|<<j].ati=nati;
lvbu[i|<<j].exp=nexp;
}
}
}
}
if(lvbu[N].hp)
cout<<lvbu[N].hp<<endl;
else
cout<<"Poor LvBu,his period was gone."<<endl;
}
}

HDU 2809 God of War (状压DP)的更多相关文章

  1. HDU 6149 Valley Numer II 状压DP

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6149 题意:中文题目 解法:状压DP,dp[i][j]代表前i个低点,当前高点状态为j的方案数,然后枚 ...

  2. HDU 5434 Peace small elephant 状压dp+矩阵快速幂

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5434 Peace small elephant  Accepts: 38  Submissions: ...

  3. HDU 1074 Doing Homework(状压DP)

    第一次写博客ORZ…… http://acm.split.hdu.edu.cn/showproblem.php?pid=1074 http://acm.hdu.edu.cn/showproblem.p ...

  4. HDU 4906 Our happy ending (状压DP)

    HDU 4906 Our happy ending pid=4906" style="">题目链接 题意:给定n个数字,每一个数字能够是0-l,要选当中一些数字.然 ...

  5. HDU 1074 Doing Homework (状压dp)

    题意:给你N(<=15)个作业,每个作业有最晚提交时间与需要做的时间,每次只能做一个作业,每个作业超出最晚提交时间一天扣一分 求出扣的最小分数,并输出做作业的顺序.如果有多个最小分数一样的话,则 ...

  6. HDU 4568 Hunter 最短路+状压DP

    题意:给一个n*m的格子,格子中有一些数,如果是正整数则为到此格子的花费,如果为-1表示此格子不可到,现在给k个宝藏的地点(k<=13),求一个人从边界外一点进入整个棋盘,然后拿走所有能拿走的宝 ...

  7. HDU 1074 Doing Homework【状压DP】

    Doing Homework Problem Description Ignatius has just come back school from the 30th ACM/ICPC. Now he ...

  8. HDU 4899 Hero meet devil (状压DP, DP预处理)

    题意:给你一个基因序列s(只有A,T,C,G四个字符,假设长度为n),问长度为m的基因序列s1中与给定的基因序列LCS是0,1......n的有多少个? 思路:最直接的方法是暴力枚举长度为m的串,然后 ...

  9. HDU 5657 CA Loves Math 状压DP + 枚举

    题意: 给出\(A(2 \leq A \leq 11), n(0 \leq n \leq 10^9), k(1 \leq k \leq 10^9)\). 求区间\([1, A^n]\)中各个数字互不相 ...

  10. HDU - 4284 Travel(floyd+状压dp)

    Travel PP loves travel. Her dream is to travel around country A which consists of N cities and M roa ...

随机推荐

  1. 自动化登录QQ脚本

    1.准备第三方包: py -3.6 -m pip install win32gui py -3.6 -m pip install Pywin32 py -3.6 -m pip install pyHo ...

  2. HTML5+CSS3制作无限滚动与文字跳动效果

    ㈠用HTML5+CSS3做无限滚动效果 ⑴逻辑分析 ⑵实践示例 前5张图片为所有图片显示区,假设总长度为1100px: 后面出现的五张图片为克隆区,只是将前面的图片拷贝了一份: 然后将前五张和后五张的 ...

  3. linux 免密码 使用sudo 直接使用root权限执行命令

    1.切换到root用户下,怎么切换就不用说了吧,不会的自己百度去. 2.添加sudo文件的写权限,命令是: chmod u+w /etc/sudoers 3.编辑sudoers文件 vi /etc/s ...

  4. Nowcoder 练习赛26 D xor序列 ( 线性基 )

    题目链接 题意 : 中文题.点链接 分析 : 对于给定的 X 和 Y 假设存在一个 Z 使得 X (xor) Z = Y 做一个变形 X (xor) Z (xor) Y = 0 X (xor) Y = ...

  5. python学习之路(7)

    调用函数 Python内置了很多有用的函数,我们可以直接调用. 要调用一个函数,需要知道函数的名称和参数,比如求绝对值的函数abs,只有一个参数.可以直接从Python的官方网站查看文档: http: ...

  6. 在mac中,npm安装或者卸载失败,提示没有权限

    在终端输入 sudo chown -R $USER /usr/local 输入开机密码

  7. Div内容居中

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  8. Java缓存技术有哪些

    我们用ehcache在本地,分布式用redis和memcache,各有各的好处,现在企业都是应用很多种中间件供俺们码农选择.

  9. Vue.js---配置开发环境

    首先安装Node.js我就不介绍了! win+r , 输入cmd,回车: 1.安装淘宝镜像 在国内直接使用npm的官方镜像是比较慢的,这里我们采用的是淘宝镜像 npm install -g cnpm ...

  10. defineProperty和defineProperties介绍

    v-model 实现的原理 angular 是 mvc 的实现原理,ng-model 是靠脏值检测实现的 脏值检测:for 循环一个个对比 vue 靠的是数据劫持 和 发布者,订阅者模式 数据劫持:O ...