Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

这是一道数学题

Posted by aoxboxcox at 2020-11-05 11:26:37 on Problem 1787
总金额P,硬币种类1,5,10,25
所以(P mod 5)一定是1构成的,再余下的1一定是5个5个地用,并且能用多少就用多少。

这样总金额和硬种就都可以除以5了,于是原题转换为:
总金额p=P/5,硬币种类1,2,5
x+2y+5z=p 其中x<=C2+(C1-(P mod 5))/5, y<=C3, z<=C4

易证:
对一个给定的x,如果可以找到一组可行解,那么让x再减2一定得不到最优解。

解法:
从大往小遍历x
  对于每个给定的x,求对应的最优解y和z(y要尽量大,通过p-x的奇偶性易解)
  此外,若给定x有可行解,再检查一下x-1就可以了。

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator