Minimum money to buy books

Source: Internet
Author: User

Question 1: Buy Books

A bookstore has introduced a set of books with a total of 3 volumes. Each volume is priced at 60 yuan. The bookstore has launched an activity to engage in promotions. The activity is as follows:

If you purchase one of these volumes separately, you can enjoy a 9.5 discount.

If you purchase two different volumes at the same time, you can get a discount.

If you purchase three different volumes at the same time, you can get a 8.5 discount.

If James wants to purchase 1st-Volume X, 2nd-volume Y, and 3rd-volume Z, what is the minimum cost? (X, y, and z are three known integers ).

 

Of course, this question can be solved without dynamic planning. But now we want to learn dynamic planning. So, please think about how to use dynamic planning?

 

Answer:

 

1. The process is a one-time purchase. Each purchase may only buy one (there are three solutions), or two (there are also three solutions ), or buy three books together (there is a solution), and finally buy all the required books.

2. In the last step, I will definitely select one of the seven purchase schemes. Therefore, I want to select the best one among the seven purchase schemes.

3. The sub-question is, after I select a scheme, how can I make the purchase of the remaining books use the least money? This option does not make the remaining books negative. Both the primary and subquestions are given the purchase volume of three books, and the minimum amount of money is required. Therefore, there are "overlapping subquestions". The three purchase volumes in the question are set as parameters, they are I, j, and K.

4. It does.

5. the boundary is to buy all the books at a time. Please consider the solution yourself.

6. A maximum of seven solutions can be selected at a time, and multiple solutions will not be implemented at the same time. Therefore, the selection of solutions does not affect each other. Therefore, "sub-problems are independent ".

7. I can use minmoney [I] [J] [k] To save the minimum money required to purchase 1st-Volume I, 2nd-volume J, and 3rd-volume K.

8. There are a total of x * y * Z problems. Each problem has seven options: O (x * y * z * 7) = O (x * y * z ).

9. The minmoney (I, j, k) function is used to indicate the minimum money required to purchase 1st-Volume I, 2nd-volume J, and 3rd-volume K. There are:

Minmoney (I, j, k) = min (S1, S2, S3, S4, S5, S6, S7), where S1, S2, S3, S4, S5, S6, s7 is the minimum money used by the corresponding 7 solutions:

S1 = 60*0.95 + minmoney (I-1, j, k)

S2 = 60*0.95 + minmoney (I, J-1, K)

S3 = 60*0.95 + minmoney (I, j, k-1)

S4 = (60 + 60) * 0.9 + minmoney (I-1, J-1, K)

S5 = (60 + 60) * 0.9 + minmoney (I-1, J, k-1)

S6 = (60 + 60) * 0.9 + minmoney (I-1, J, k-1)

S7 = (60 + 60 + 60) * 0.85 + minmoney (I-1, J-1, k-1)

 

 

Minimum money to buy books

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.