文件名称:324
-
所属分类:
- 标签属性:
- 上传时间:2012-11-16
-
文件大小:1.03kb
-
已下载:0次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
算法实现题3-1 最少硬币问题
问题描述:设有n种不同面值的硬币,各硬币的面值存于数组T[1:n]中。现要用这些面值的硬币来找钱。可以使用的各种面值的硬币个数存于数组Coins[1:n]中。对任意钱数0≤m≤20001,设计一个用最少硬币找钱m的方法。
算法设计:对于给定的1≤n≤10,硬币面值数组T和可以使用的各种面值的硬币个数数组Coins,以及钱数m,0≤m≤20001,计算找钱m的最少硬币数。
数据输入:由文件input.txt 提供输入数据,文件的第一行中只有1 个整数给出n的值,第2 行起每行2 个数,分别是T[j]和Coins[j]。最后1 行是要找的钱数m。
结果输出: 将计算出的最少硬币数输出到文件output.txt中。问题无解时输出-1。-Algorithm to achieve the title 3-1 at least coins Descr iption: There are n kinds of different denominations of coins, the nominal value of each coin is stored in an array T [1: n]. Now use these nominal value of the coins came to money. The number of coins of various denominations that can be used is stored in an array of Coins is [1: n]. Any money 0 ≤ m ≤ 20 001, design a minimum of coins to give change m the method. Algorithm design: For a given 1 ≤ n ≤ 10 Coins come in denominations of array T and can use the various denominations of coins in the number of array Coins, as well as money m, 0 ≤ m ≤ 20 001, calculate the minimum number of coins to find the money m. Data Input: input data from the file input.txt, the first line of the file, given an integer value of n, since each line number in line 2, respectively, T [j] and Coins is [j]. The last line is looking for money m. The results of the output: calculate the minimum number of coins output to the file output.txt. Problem has no
问题描述:设有n种不同面值的硬币,各硬币的面值存于数组T[1:n]中。现要用这些面值的硬币来找钱。可以使用的各种面值的硬币个数存于数组Coins[1:n]中。对任意钱数0≤m≤20001,设计一个用最少硬币找钱m的方法。
算法设计:对于给定的1≤n≤10,硬币面值数组T和可以使用的各种面值的硬币个数数组Coins,以及钱数m,0≤m≤20001,计算找钱m的最少硬币数。
数据输入:由文件input.txt 提供输入数据,文件的第一行中只有1 个整数给出n的值,第2 行起每行2 个数,分别是T[j]和Coins[j]。最后1 行是要找的钱数m。
结果输出: 将计算出的最少硬币数输出到文件output.txt中。问题无解时输出-1。-Algorithm to achieve the title 3-1 at least coins Descr iption: There are n kinds of different denominations of coins, the nominal value of each coin is stored in an array T [1: n]. Now use these nominal value of the coins came to money. The number of coins of various denominations that can be used is stored in an array of Coins is [1: n]. Any money 0 ≤ m ≤ 20 001, design a minimum of coins to give change m the method. Algorithm design: For a given 1 ≤ n ≤ 10 Coins come in denominations of array T and can use the various denominations of coins in the number of array Coins, as well as money m, 0 ≤ m ≤ 20 001, calculate the minimum number of coins to find the money m. Data Input: input data from the file input.txt, the first line of the file, given an integer value of n, since each line number in line 2, respectively, T [j] and Coins is [j]. The last line is looking for money m. The results of the output: calculate the minimum number of coins output to the file output.txt. Problem has no
(系统自动生成,下载前可以参看下载内容)
下载文件列表
324.c
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.