Poj 1252 euro efficiency (full backpack)

Source: Internet
Author: User

Http://poj.org/problem? Id = 1252

Calculate the sum of the six coins, F [J] = min (F [J], F [J-data [I] + 1 );

Then, when the value is 0, F [J] = min (F [J], F [J + data [I] + 1) is calculated );

The calculation limit is greater than 100, because there is a change of zero, but it is not very good to determine how large it is.

Code:

# Include <cstdio>
# Include <cstring>
# Include <algorithm>
Using namespace STD;
Const int max = 2500 ;//..
Int data [6], F [Max];
Int main (){
Int t, n, I, j, sum, Max;
Scanf ("% d", & T );
While (t --){
For (I = 0; I <6; I ++)
Scanf ("% d", & Data [I]);
F [0] = 0;
For (I = 1; I <Max; I ++)
F [I] = 2000000;
For (I = 0; I <6; I ++) // sum
For (j = data [I]; j <Max; j ++)
F [J] = min (F [J], F [J-data [I] + 1 );
For (I = 0; I <6; I ++) // subtract
For (j = max-data [I]; j> = 1; j --)
F [J] = min (F [J], F [J + data [I] + 1 );
Sum = max = 0;
For (I = 1; I <= 100; I ++ ){
Sum + = f [I];
If (F [I]> MAX) max = f [I];
}
Printf ("%. 2lf % d \ n", (double) sum/100, max );
}
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.