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