Coins 0
InterviewTime limit1sMemory limit256 MB
Pay exactly K with the fewest coins from denominations where each divides the next.
- Level
Easy3 of 10
- Topics
- Greedy
- Solved
- No attempts yet
Problem
You have unlimited coins of denominations. Denominations are sorted ascending, , and each is a multiple of . Find the minimum number of coins whose total value is exactly .
Input
Line 1: and (, ). Next lines: coin values in ascending order ().
Output
Print the minimum coin count.