hdu-3008 Warcraft

Source: Internet
Author: User
Tags rounds

This topic is quite interesting, playing Warcraft for many people is not unfamiliar, and boss of HP are 100, people first attack, people's general attack is 1, there is so weak wood! Fortunately, the skills are their own input, or really no words.
OK, the problem is to use dynamic programming, mainly to see the state equation, the state equation is not unique, you can set F[I][J] to indicate that the second attack is the maximum damage caused by the remaining Blue J, also can set the damage J caused by the I attack the blue amount, anyway, this problem state equation is not unique, This is the first state equation I wrote, the variables a bit more, but to find the key, in fact, are clouds. State equation: F[i][j-a[k]+t]=max (f[i][j-a[k]+t],f[i-1][j]+b[k]);

#include <iostream>#include <cstring>#include <cstdio>#include <algorithm>using namespace STD;intf[101][101];intMain () {intN,t,q;inta[101],b[101];intTime while(Cin>>n>>t>>q&& (n+t+q)) {memset(f,-1,sizeof(f));//Initialize to-1         for(intI=1; i<=n; i++) {Cin>>a[i]>>b[i]; } f[0][ -]=0; a[0]=0; b[0]=1; Time= -/q;//Indicates the maximum number of rounds a person passes        if( -%q!=0) time++;intans=-1; for(intI=1; i<=time; i++) { for(intj=0; j<= -; J + +)//Indicates the remaining blue amount                if(f[i-1][j]!=-1)                { for(intk=0; k<=n; k++)//Use skills{if(J>=a[k])//Current blue amount can support A[k] skill release, into the loop{F[i][j-a[k]+t]=max (f[i][j-a[k]+t],f[i-1][j]+b[k]);//State equation                              if(f[i][j-a[k]+t]>= -)//damage more than 100, the record is the first few rounds{ans=i; Break; }                        }if(ans!=-1) Break; }                }if(ans!=-1) Break; }if(ans==-1)cout<<"My God"<<endl;Else            cout<<ans<<endl; }return 0;}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

hdu-3008 Warcraft

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.