【HDOJ】2809 God of War
2015-01-23 23:42
357 查看
状态DP。
/* 2809 */ #include <iostream> #include <queue> #include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm> using namespace std; #define MAXN 20 typedef struct { int a, d, h, e; } hero_t; hero_t hero[MAXN]; int dp[1<<MAXN]; int exp[1<<MAXN]; int mask[MAXN]; bool visit[1<<MAXN]; char name[25]; queue<int> Q; int main() { int n, m, size; int la, ld, lh; int ia, id, ih; int ra, rb, ha, hb; int i, j, k, tmp; int s, ss; int slev, alev, dlev, hlev, sslev; #ifndef ONLINE_JUDGE freopen("data.in", "r", stdin); #endif mask[0] = 1; for (i=1; i<MAXN; ++i) mask[i] = (mask[i-1]<<1); while (scanf("%d%d%d%d%d%d", &la,&ld,&lh, &ia,&id,&ih) != EOF) { scanf("%d", &n); for (i=0; i<n; ++i) scanf("%s %d %d %d %d", name, &hero[i].a,&hero[i].d,&hero[i].h,&hero[i].e); m = 1<<n; memset(dp, 0, sizeof(int)*m); memset(visit, false, sizeof(bool)*m); dp[0] = lh; exp[0] = 0; Q.push(0); visit[0] = true; while (!Q.empty()) { s = Q.front(); Q.pop(); visit[s] = false; for (i=0; i<n; ++i) { if (s & mask[i]) continue; ss = s | mask[i]; // calculate s-state level slev = exp[s]/100; alev = la+slev*ia; dlev = ld+slev*id; // calculate hurt and round ha = max(1, alev-hero[i].d); hb = max(1, hero[i].a-dlev); ra = (hero[i].h+ha-1)/ha; rb = (dp[s]+hb-1)/hb; if (ra > rb) continue; // LvBu Lose exp[ss] = exp[s] + hero[i].e; sslev = exp[ss]/100; // calculate new hp tmp = dp[s] - (ra-1)*hb + (sslev-slev)*ih; dp[ss] = max(dp[ss], tmp); if (visit[ss] == false) { visit[ss] = true; Q.push(ss); } } } if (dp[m-1]) printf("%d\n", dp[m-1]); else printf("Poor LvBu,his period was gone.\n"); } return 0; }
相关文章推荐
- HDU 2809 God of War
- HDU - 2809 God of War (DP+状态压缩)
- HDU 2809 God of War(DP + 状态压缩)
- hdu 2809 God of War //状态压缩DP
- hud 2809 God of War
- hdu 2809 God of War
- hdu 2809 God of War
- God of War - HDU 2809(状态压缩+模拟)
- hdu 2809 God of War(动态规划之状态压缩)
- HDU 2809 God of War
- 下载!《忍者杀手 Ninja Assassin》感觉就像God of War
- 《God of War 3 / 战神3》图文攻略
- 《God of War 2 / 战神2》图文攻略 (Update:2007.7.18)
- 战神3 God of warIII, 你们准备好了吗?
- God of War Ascension / 战神4, 再一次迎来新导演!
- God of War III 的发售日期?
- 《God of War 2 / 战神2 》USA ISO, DVD9,6.6G,PS2 Game (Update:2007.5.30)
- PSP 战神 奥林匹斯之链(God of War: Chains of Olympus) 试玩版 下载地址
- 明天你就可以拿到《God of War 2》
- The Making of God of War III