Pro.ID21159 TitleMaking Change Title链接http://10.20.2.8/oj/exercise/problem?problem_id=21159 AC13 Submit60 Ratio21.67% 时间&空间限制描述Poor Bessie has taken a job in the convenience store located just over the border in Slobbovia. Slobbovians use different coinages than the USA; their coin values change day-by-day! Help Bessie make optimal change for Slobbovian shoppers. You will need to create C (1 ≤ C ≤ 1000) cents of change using N (1 ≤ N ≤ 10) coins of various values. All test cases will be solvable using the supplied coins. If 5 coins of values 50, 25, 10, 5, and 1 were available, Bessie would make optimum change (minimal coins) of 93 cents by using 1 × 50, 1 × 25, 1 × 10, 1 × 5, and 3 × 1 coins (a total of 7 coins). How hard could it be? The final two test cases will be challenging. 输入Multiple test cases, for each case: * Line 1: Two space-separate integers: C and N * Lines 2..N+1: Each line contains a single unique integer that is a coin value that can be used to create change 输出Description Poor Bessie has taken a job in the convenience store located just over the border in Slobbovia. Slobbovians use different coinages than the USA; their coin values change day-by-day! Help Bessie make optimal change for Slobbovian shoppers. You will need to create C (1 ≤ C ≤ 1000) cents of change using N (1 ≤ N ≤ 10) coins of various values. All test cases will be solvable using the supplied coins. If 5 coins of values 50, 25, 10, 5, and 1 were available, Bessie would make optimum change (minimal coins) of 93 cents by using 1 × 50, 1 × 25, 1 × 10, 1 × 5, and 3 × 1 coins (a total of 7 coins). How hard could it be? The final two test cases will be challenging. Input Multiple test cases, for each case: * Line 1: Two space-separate integers: C and N * Lines 2..N+1: Each line contains a single unique integer that is a coin value that can be used to create change Output * Line 1: A single integer that is the minimum number of coins to create C cents Sample Input 93 5 Sample Output 7 Source 样例输入93 5 样例输出7 作者 |