Buy minimum items without change and given coins |  ; See if we can buy less than 10 items Using 10 Rs coins and one r Rs coin ; We can always buy 10 items ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int minItems ( int k , int r ) { for ( int i = 1 ; i < 10 ; i ++ ) if ( ( i * k - r ) % 10 == 0 || ( i * k ) % 10 == 0 ) return i ; return 10 ; } int main ( ) { int k = 15 ; int r = 2 ; cout << minItems ( k , r ) ; return 0 ; }