"BZOJ1042" "DP + Tolerant" [HAOI2008] coin Shopping

Source: Internet
Author: User
Description

Coin shopping A total of 4 kinds of coins. The denominations were c1,c2,c3,c4. Someone went to the store to buy something and went to tot. Each time with a di ci coin, buy something of Si value. How many methods of payment do you have each time?

Input

The first line C1,c2,c3,c4,tot under the Tot line d1,d2,d3,d4,s

Output

Number of methods per time

Sample Input1 2 5 10 2
3 2 3) 1 10
2 2 2, Sample Output4
HINT

Data size
di,s<=100000
tot<=1000

Analysis

Isn't it math? Let's also count math ...

The pretreatment is performed to find out the total number of schemes F (i) for which the value I is obtained under the condition that the coin can be taken.

Then the tolerance total exceeds the limit-1 exceeds the limit-2 exceeds the limit-3 exceeds the limit-4 exceeds the Limit + 1, 2 exceeds the limit ...

How do you count 1 over the limit? Set S to the total value, 1 of the limit is d[i], the value is C[i], then 1 exceeds the limit of F[s-(D[i] + 1) * C[i]].

Code complexity is very low, do not write.

"BZOJ1042" "DP + Tolerant" [HAOI2008] coin Shopping

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.