Data Structures & AlgorithmsHardCodeforces Div 2 · ICPC regional
Coins of denominations [9, 8, 7, 2] are available in unlimited quantity. What is the minimum number of coins needed to pay exactly 22? (Coins may be used any number of times; the answer must sum exactly.)
- A. 22
- B. 4
- C. 3
- D. 7
Correct answer: C. 3
The unbounded DP gives 3 coins. The greedy largest-first rule uses 4, which is the trap when denominations are not canonical.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- Directed acyclic graph on vertices A, B, C, D, E, F, G (every edge goes from a smaller to a larger letter) with weighted edges A→C (9)…
- Connected undirected weighted graph on vertices A, B, C, D with edges A–B (6), A–D (5), B–C (3), B–D (4), C–D (4). Among all spanning…
- Directed acyclic graph on vertices A, B, C, D, E, F with edges A→F, A→C, A→E, F→D, B→E, D→C. Among all topological orderings (every edge…
- Directed acyclic graph on vertices A, B, C, D, E, F with edges B→D, A→F, A→E, D→E, F→C. Among all topological orderings (every edge goes…
- Connected undirected weighted graph on vertices A, B, C, D, E with edges A–C (6), A–D (6), B–C (1), B–D (5), C–E (4), D–E (4). Among all…
- A 6 × 6 grid (rows top to bottom, '#' = filled, '.' = empty): ...... / ..#... / .#.### / ....#. / #...## / .#..#.. Two filled cells belong…