GATE Computer ScienceHardGATE CS (PYQ pattern)

Using unlimited coins of denominations 2, 5, 7 and 10 (order does not matter), how many ways are there to pay exactly 40 using at most 6 coins?

  1. A. 34
  2. B. 3
  3. C. 4
  4. D. 5

Correct answer: D. 5

Grouping all 34 combinations by coin count: 4 coins: 10+10+10+10; 5 coins: 10+10+10+5+5; 6 coins: 5+7+7+7+7+7, 5+5+5+5+10+10 and 2+7+7+7+7+10. Total 1 + 1 + 3 = 5. Without the limit there are 34 ways.

More Algorithms questions

Exams that ask this topic