#K7596. Minimum Coins Summation
Minimum Coins Summation
Minimum Coins Summation
Given a target integer n, your task is to determine the minimum number of coins required to sum exactly to n using coins of denominations \(1\), \(2\), and \(5\). Since every positive integer can be formed using these coins, there will always be a solution for n \ge 0. If for any reason the sum cannot be achieved exactly, output \(-1\) (although this case will not occur with the given denominations).
Note: The coin system \(1,2,5\) is canonical, meaning that a greedy algorithm will yield the optimal solution.
inputFormat
The input consists of a single line containing an integer \(n\) where \(0 \leq n \leq 10^9\).
outputFormat
Output a single integer representing the minimum number of coins required to sum exactly to \(n\).
## sample7
2