硬币的最小数目的总和是S目的、小数、总和、硬币

由网友(绽放的菊花)分享简介:给定N硬币的列表,它们的值(V1,V2,...,VN),并且总和S.查找硬币的最小数目的总和为S(我们可以用尽可能多的硬币一种类型的,因为我们希望),或报告,它是不可能以这样的方式选择的硬币,他们总结至S. Given a list of N coins, their values (V1, V2, ... , VN...

给定N硬币的列表,它们的值(V1,V2,...,VN),并且总和S.查找硬币的最小数目的总和为S(我们可以用尽可能多的硬币一种类型的,因为我们希望),或报告,它是不可能以这样的方式选择的硬币,他们总结至S.

Given a list of N coins, their values (V1, V2, ... , VN), and the total sum S. Find the minimum number of coins the sum of which is S (we can use as many coins of one type as we want), or report that it's not possible to select coins in such a way that they sum up to S.

我试着去了解动态规划,还没有意识到这一点。我不明白的给出解释,所以也许你可以把我一些提示如何编程这个任务?没有code,只是想法我应该在哪里开始。

I try to understand dynamic programming, haven't figured it out. I don't understand the given explanation, so maybe you can throw me a few hints how to program this task? No code, just ideas where I should start.

感谢。

推荐答案

这是一个经典的背包问题,看看这里的一些信息的维基百科背包问题

This is a classic Knapsack problem, take a look here for some more information: Wikipedia Knapsack Problem

您应该也看一些整理,特别是从最大到最小值排序。

You should also look at some sorting, specifically sorting from Largest to Smallest values.

阅读全文

相关推荐

最新文章