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. (转)Android中图片占用内存计算

    在Android开发中,我现在发现很多人还不会对图片占用内存进行很好的计算.因此撰写该博文来做介绍,期望达到抛砖引玉的作用.   Android中一张图片(BitMap)占用的内存主要和以下几个因数有 ...

  2. 如何在输入命令行npm run dev 之后vue项目自动在浏览器打开

    使用代码编辑器打开vue项目代码,在config文件夹里面找到index.js 将里面的:autoOpenBrowser: false, 修改为 :autoOpenBrowser: true, 这个方 ...

  3. codevs2370 小机房的树 x

    2370 小机房的树  时间限制: 1 s  空间限制: 256000 KB  题目等级 : 钻石 Diamond   题目描述 Description 小机房有棵焕狗种的树,树上有N个节点,节点标号 ...

  4. HGOI 20190711 题解

    Problem A 矩阵第K小数 给定一个$n \times m$的矩阵,位置$A_{i,j}  = i\times j$, 给出$Q$个询问,每一次查询矩阵中第$Q_i$小的数是多少. 对于100% ...

  5. python之timeit模块

    timeit模块: timeit 模块定义了接受两个参数的 Timer 类.两个参数都是字符串. 第一个参数是你要计时的语句或者函数. 传递给 Timer 的第二个参数是为第一个参数语句构建环境的导入 ...

  6. idea中JSP页面不能访问静态资源(图片,js,css)

    必须配置SpringMvc对访问静态资源的支持,idea默认就是在main/webapp 下的文件路径,要在web-info同级的resource文件下放置,JSP中 ${pageContext.re ...

  7. Socket编程-基础使用

    最后更新:2019-10-25 一 基本概念 socket, 又称为"套接字"或者"插座". 是操作系统提供的一种进程间通信机制.目前大多用于不同网络设备之间的 ...

  8. Java面试题收集(二)

    四.Redis简介 redis为什么这么快 4.1 Redis数据类型 String hash 字典,适用于存储对象 list 安照String元素插入顺序排序,最新插入的最先显示.如热点数据 set ...

  9. spark 笔记 16: BlockManager

    先看一下原理性的文章:http://jerryshao.me/architecture/2013/10/08/spark-storage-module-analysis/ ,http://jerrys ...

  10. leetcode-easy-listnode-206 reverse linked list

    mycode   98.87 # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x ...