摘要:
问题:有3,5,7分钱的硬币,以及给定的数额N,求找开N所需的最小硬币数目。扩展问题:有(V1, V2, V3, ..., Vm)硬币面额,面额数目为m,以及给定的数额N,求找开N所需的最小硬币数目,或断定不能找开。硬币找零是比较经典的动态规划问题,在某些面额组合的情况下,可以用贪心算法求解。《算法导论》中将硬币找零问题作为贪心算法的例子。在这里,随机选取三个素数作为面额。对于某一数额N,若能被给定的面额找开,可以分为两种情况。1、N恰好等于某一硬币的面额,这样找开N只需一枚硬币;2、N需要多枚硬币才能找开。现在主要分析第二种情况。当一枚硬币找不开时,则数额N一定可以被分为两个子数额N1,N2 阅读全文
摘要:
Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Problem Description"Well, it seems the first problem is too easy. I will let you know how foolish you are later." feng5166 says."The second problem is, given an positive integer N, we define an equation lik 阅读全文
摘要:
Maximum EnergyTime Limit:1000MS Memory Limit:32768KDescription:Bobwanted to increase his energy by eating AC-APPLEs. There are N(1 <= N <= 150,000) AC-APPLEs, each AC-APPLE had a magic value "v" which is a positive interger and not bigger than 500. Bob visited AC-APPLEs which are giv 阅读全文