HDU 2809 God of War
2015-07-18 23:14
696 查看
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
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. 状态压缩dp#include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<iostream> #include<vector> #include<set> #include<map> #include<queue> #include<string> using namespace std; const int maxn = 1 << 20; int n, ia, id, ihp, N; string s; struct fighter { int a, d, hp, ex; fighter(){ a = d = hp = ex = 0; } void read(){ cin >> s >> a >> d >> hp >> ex; } void clear(){a = d = hp = ex = 0;} }f[maxn],a[30]; bool operator <(const fighter&a, const fighter&b) { return a.hp < b.hp; } fighter operator +(const fighter&a, const fighter&b) { fighter c = a; int x = (b.hp + max(1, a.a - b.d) - 1) / max(1, a.a - b.d); int y = (a.hp + max(1, b.a - a.d) - 1) / max(1, b.a - a.d); if (x>y) { c.hp = 0; return c; } c.hp -= max(1, b.a - a.d)*(x - 1); c.ex += b.ex; for (int i = 1; i <= n; i++) if (a.ex < 100 * i&&c.ex >= 100 * i) { c.a += ia; c.d += id; c.hp += ihp; break; } return c; } int main() { while (cin >> f[0].a >> f[0].d >> f[0].hp) { cin >> ia >> id >> ihp >> n; for (int i = 0; i < n; i++) a[i].read(); N = (1 << n) - 1; for (int i = 1; i <= N; i++) { f[i].clear(); for (int j = 0; j < n; j++) if (i&(1<<j)) f[i] = max(f[i], f[i ^ (1 << j)] + a[j]); } if (f .hp>0) cout << f .hp << endl; else cout << "Poor LvBu,his period was gone." << endl; } return 0; }
相关文章推荐
- UGO权限问题
- Django 分页 django-pagination
- 【Go语言】【15】GO语言的面向对象
- 【Go语言】【15】GO语言的面向对象
- fonts.googleapis.com, ajax.googleapis.com加载缓慢的解决方法
- Django的URLconf中使用缺省视图参数的方法
- Algorithm Analysis 算法分析
- 国内使用Google搜索的技巧
- 在Django框架中伪造捕捉到的URLconf值的方法
- 有趣的游戏:Google XSS Game
- django 简单会议室预约(4)
- Django中传递参数到URLconf的视图函数中的方法
- 在Django的URLconf中使用命名组的方法
- 在Go语言里检测内存泄漏
- 在Django的URLconf中使用多个视图前缀的方法
- 在Django的URLconf中进行函数导入的方法
- GO语言练习:channel 缓冲机制
- Django笔记 —— 基础部分总结
- 在Django的视图中使用form对象的方法
- 详解Django中的form库的使用