Hdu 1085 Holding Bin-Laden Captive! (Primary function)

Source: Internet
Author: User

Hdu 1085 Holding Bin-Laden Captive! (Primary function)

 

 

Meaning: 1 RMB, 2 RMB, and 5 RMB coins include num [1], num [2], and num [3. Ask the minimum amount of money that cannot be combined with these coins.

 

Continue the master function.

There are two notes:

You must also initialize c1 [] During c2 [] initialization.

Finally, sum + 1 is enumerated, because [1, sum] may all be possible. In this case, sum + 1 is output.

 

 

# Include
 
  
# Include
  
   
# Include
   # Include
    
     
# Include
     
      
# Include
      
        # Include
       
         # Include
        
          # Include
         
           # Include
          
            # Include
           
             # Include # define LL long # define _ LL _ int64 # define eps 1e-12 # define PI acos (-1.0) using namespace std; int c1 [8010], c2 [8010]; int add [4] = {,}; int num [4]; int main () {while (~ Scanf (% d, & num [1], & num [2], & num [3]) {if (num [1] = 0 & num [2] = 0 & num [3] = 0) break; int sum = num [1] + num [2] * 2 + num [3] * 5; // maximum amount of money that can be reached memset (c2, 0, sizeof (c2); memset (c1, 0, sizeof (c1); for (int I = 0; I <= num [1]; I ++) {c1 [I] = 1 ;}for (int I = 2; I <= 3; I ++) {for (int j = 0; j <= sum; j ++) {for (int k = 0; k + j <= sum & k <= add [I] * num [I]; k + = add [I]) {c2 [k + j] + = c1 [j] ;}} for (int j = 0; j <= sum; j ++) {c1 [j] = c2 [j]; c2 [j] = 0 ;}}for (int I = 1; I <= sum + 1; I ++) // note that sum + 1 is enumerated, because if [1, sum] can be merged, sum + 1 should be output. {if (c1 [I] = 0) {printf (% d, I); break ;}} return 0 ;}
           
          
         
        
       
      
     
    
  
 


 

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.