Problem
You have unlimited coins of value 1 and value 3.
What is the minimum number of coins needed to make exactly N euros?
What is the minimum number of coins needed to make exactly N euros?
š§ DP Concept
dp[i] = minimum coins to make exactly i euros.Base case: dp[0] = 0 (zero euros needs zero coins).
Recurrence: For each i ā„ 1:
ā Option A: use a 1-coin ā dp[iā1] + 1
ā Option B (if i ā„ 3): use a 3-coin ā dp[iā3] + 1
ā dp[i] = min of the available options.
š” Use an if/else to handle i < 3 (only option A available) vs i ā„ 3 (both options).
Input Variables (pre-loaded)
š” Drag N, set dp[i], get dp[i], and the min block from the toolbox.
Your Output
Result
ā
Run your program to see the result.
Execution Log
Ready. Press ā¶ Run to start.
Expected Answer
Answer:
?
Hint
Step 0