text: Minimize coins required to obtain all possible values up to N | Function to find minimum count of { 1 , 2 , 5 } valued coins required to make a change of all values in the range [ 1 , N ] ; Number of 5 valueds coins required ; Number of 1 valued coins required ; Number of 2 valued coins required ; Driver Code
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; void find ( int N ) { int T , F , O ; F = int ( ( N - 4 ) / 5 ) ; if ( ( ( N - 5 * F ) % 2 ) == 0 ) { O = 2 ; } else { O = 1 ; } T = floor ( ( N - 5 * F - O ) / 2 ) ; cout << " Count ▁ of ▁ 5 ▁ valueds ▁ coins : ▁ " << F << endl ; cout << " Count ▁ of ▁ 2 ▁ valueds ▁ coins : ▁ " << T << endl ; cout << " Count ▁ of ▁ 1 ▁ valueds ▁ coins : ▁ " << O << endl ; } int main ( ) { int N = 8 ; find ( N ) ; return 0 ; }