]]>HDU2809 God of War(鍔ㄦ佽鍒掍箣鐘舵佸帇緙╋級http://www.shnenglu.com/doer-xee/archive/2009/11/26/102003.html瑗塊钀х憻瑗塊钀х憻Thu, 26 Nov 2009 12:46:00 GMThttp://www.shnenglu.com/doer-xee/archive/2009/11/26/102003.htmlhttp://www.shnenglu.com/doer-xee/comments/102003.htmlhttp://www.shnenglu.com/doer-xee/archive/2009/11/26/102003.html#Feedback0http://www.shnenglu.com/doer-xee/comments/commentRss/102003.htmlhttp://www.shnenglu.com/doer-xee/services/trackbacks/102003.htmlhttp://acm.hdu.edu.cn/showproblem.php?pid=2809 HH澶х墰鍑虹殑棰樼洰錛屾瘮璧涚殑鏃跺欒鍞綇浜嗘病鏈夊幓鍋氾紝浠婂ぉ鍏磋嚧鏉ヤ簡璁ょ湡鏁蹭簡涓涓嬶紝縐掓潃 榪欓璺?074doing homework涓鏍鳳紝浣嶅帇緙╋紝娌$殑璇達紝鑷簳鍚戜笂璁$畻錛岃鍥?br>
#include<iostream> usingnamespace std; #define N 1100000 int m,n,hp,ati,def; struct node{ int ati; int def; int hp; int lv; int exp; }q[N],tt; struct man{ int ati; int def; int hp; int exp; }man[21]; int max(int a,int b) { return a>b?a:b; } int war(int j,int i) { int time; time=man[i].hp/max(1,q[j].ati-man[i].def); if(man[i].hp%max(1,q[j].ati-man[i].def)==0) time--; if(time>=0) return time; return-1; } void dp() { int i,j,time,add,temp,next; for(j=0;j<m;j++) { if(q[j].hp<=0) continue; for(i=0;i<n;i++) { temp=j>>i; if(temp&1) continue; else next=j+(1<<i); if((time=war(j,i))==-1) continue;//鎴樻枟澶辮觸錛宑ontinue tt=q[j]; tt.hp-=time*max(1,man[i].ati-tt.def); tt.exp+=man[i].exp; if(tt.exp>=100) { add=tt.exp/100; tt.exp%=100; tt.ati+=add*ati; tt.def+=add*def; tt.hp+=add*hp; tt.lv+=add; } if(q[next].hp==0||tt.hp>q[next].hp||(q[next].hp==tt.hp&&(tt.lv*100+tt.exp)>(q[next].lv*100+q[next].exp))) { q[next]=tt; } } q[j].hp=0; } } int main() { int i; char name[22]; while(scanf("%d%d%d%d%d%d",&q[0].ati,&q[0].def,&q[0].hp,&ati,&def,&hp)>0) { scanf("%d",&n); for(i=0;i<n;i++) scanf("%s%d%d%d%d",name,&man[i].ati,&man[i].def,&man[i].hp,&man[i].exp); m=(1<<n)-1; q[0].lv=1; q[0].exp=0; for(i=1;i<=m;i++) { q[i].hp=0; } dp(); if(q[m].hp>0) printf("%d\n",q[m].hp); else printf("Poor LvBu,his period was gone.\n"); } return0; }