Problem: Ram has to pay Shyam R rupees and but the coins which he has got is of limited denomination .Assuming he has a limited knowledge of the mathematics and has unlimited number of coins of each denomination.Write a code to help Ram to pay the money using minimum number of coins .Suppose Ram has coins of {1,2} denomination then the best way to pay 8 rupees is 2+2+2+2 that means using 4 coins.
Input:
Money to be paid
{array containing denominations available}
Output 
Coins corresponding to each denomination and number of coins needed(ascending denomination)
or print ERROR in other cases

SAMPLE INPUT
24
{1,7,3}

SAMPLE OUTPUT
Rupee 1 coin 0
Rupee 3 coin 1
Rupee 7 coin 3

Solution (in PYTHON):

Solution:
def min_coins(money, denoms):
    # money : The money which is needed to get minimum coins
    # denoms : Available denominations
    denoms.sort()
 
    min = denoms[0] * money
    coin_list = {}
 
    for j in range(len(denoms)):
        temp = money
        used = 0
        coins = {}
        for i in range(1, len(denoms) - j + 1):
            coin = temp / denoms[-(i + j)]
            used += coin
            coins[denoms[-(i+j)]] = coin
            temp %= denoms[-(i+j)]
            if(temp <= 0):
                break
 
        if(used < min and temp == 0):
            min = used
            coin_list = coins
 
    if(coin_list == {}):
        print "ERROR"
    else:
        for denom in denoms:
            print "Rupee %d coin %d" %(denom, coin_list.get(denom, 0))
 
 
money = input()
lis = raw_input().split(',')
if(len(lis) == 1):
    lis = [int(lis[0][1:-1])]
else:
    lis[0] = lis[0][1:]
    lis[-1] = lis[-1][:-1]
    lis = [int(x) for x in lis]
 
min_coins(money, lis)