"Hdoj" 2809 God of War

Source: Internet
Author: User

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", &AMP;LA,&AMP;LD,&AMP;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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.