I'm trying to solve this problem:
Suppose I have a set of n coins {a_1, a2, ..., a_n}. A coin with value 1 will always appear. What is the minimum number of coins I need to reach M?
The constraints are:
- 1 ≤ n ≤ 25
- 1 ≤ m ≤ 10^6
- 1 ≤ a_i ≤ 100
Ok, I know that it's the Change-making problem. I have tried to solve this problem using Breadth-First Search, Dynamic Programming and Greedly (which is incorrect, since it don't always give best solution). However, I get Time Limit Exceeded (3 seconds).
So I wonder if there's an optimization for this problem. The description and the constraints called my attention, but I don't know how to use it in my favour:
- A coin with value 1 will always appear.
- 1 ≤ a_i ≤ 100
I saw at wikipedia that this problem can also be solved by "Dynamic programming with the probabilistic convolution tree". But I could not understand anything.
Can you help me? This problem can be found here: http://goo.gl/nzQJem