Status DP.
1 /*2809*/2#include <iostream>3#include <queue>4#include <cstdio>5#include <cstring>6#include <cstdlib>7#include <algorithm>8 using namespacestd;9 Ten #defineMAXN 20 One Atypedefstruct { - intA, D, H, E; - } hero_t; the - hero_t HERO[MAXN]; - intdp[1<<MAXN]; - intexp[1<<MAXN]; + intMASK[MAXN]; - BOOLvisit[1<<MAXN]; + Charname[ -]; Aqueue<int>Q; at - intMain () { - intN, m, size; - intLA, LD, LH; - intia, ID, IH; - intRA, RB, ha, HB; in intI, J, K, TMP; - ints, SS; to intSlev, Alev, Dlev, Hlev, Sslev; + - #ifndef Online_judge theFreopen ("data.in","R", stdin); * #endif $ Panax Notoginsengmask[0] =1; - for(i=1; i<maxn; ++i) theMask[i] = (mask[i-1]<<1); + A while(SCANF ("%d%d%d%d%d%d", &LA,&LD,&LH, &ia,&id,&ih)! =EOF) { thescanf"%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; theexp[0] =0; -Q.push (0);Wuyivisit[0] =true; the while(!Q.empty ()) { -s =Q.front (); Wu Q.pop (); -Visit[s] =false; About for(i=0; i<n; ++i) { $ if(S &Mask[i]) - Continue; -SS = S |Mask[i]; - //Calculate s-state level ASlev = exp[s]/ -; +Alev = la+slev*ia; theDlev = ld+slev*ID; - //calculate hurt and round $HA = Max (1, alev-hero[i].d); theHB = MAX (1, hero[i].a-Dlev); theRA = (hero[i].h+ha-1)/ha; theRB = (dp[s]+hb-1)/HB; the if(Ra >RB) - Continue;//Lvbu lose inEXP[SS] = Exp[s] +hero[i].e; theSslev = exp[ss]/ -; the //Calculate new HP AboutTMP = Dp[s]-(ra-1) *HB + (Sslev-slev) *IH; theDP[SS] =Max (DP[SS], TMP); the if(Visit[ss] = =false) { theVISIT[SS] =true; + Q.push (ss); - } the }Bayi } the if(dp[m-1]) theprintf"%d\n", dp[m-1]); - Else -printf"Poor lvbu,his period was gone.\n"); the } the the return 0; the}
"Hdoj" 2809 God of War