硬币的最小数目的总和是S [英] The minimum number of coins the sum of which is S

查看:138
本文介绍了硬币的最小数目的总和是S的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定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.

这篇关于硬币的最小数目的总和是S的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆