Problem:


		
Problem B: Make Purse Light

		

			Mr. Bill は店で買い物をしている。 彼の財布にはいくらかの硬貨（10 円玉、50 円玉、100 円玉、500 円玉）が入っているが、彼は今この小銭をできるだけ消費しようとしている。 つまり、適切な枚数の硬貨によって品物の代金を払うことで、釣り銭を受け取った後における硬貨の合計枚数を最小にしようとしている。
		

		

			幸いなことに、この店の店員はとても律儀かつ親切であるため、釣り銭は常に最適な方法で渡される。 したがって、例えば 1 枚の 500 円玉の代わりに 5 枚の 100 円玉が渡されるようなことはない。 また、例えば 10 円玉を 5 枚出して、50 円玉を釣り銭として受け取ることもできる。 ただし、出した硬貨と同じ種類の硬貨が釣り銭として戻ってくるような払いかたをしてはいけない。 例えば、10 円玉を支払いの際に出したにも関わらず、別の 10 円玉が釣り銭として戻されるようでは、完全に意味のないやりとりが発生してしまうからである。
		

		

			ところが Mr. Bill は計算が苦手なため、実際に何枚の硬貨を使用すればよいかを彼自身で求めることができなかった。 そこで、彼はあなたに助けを求めてきた。 あなたの仕事は、彼の財布の中にある硬貨の枚数と支払い代金をもとに、使用すべき硬貨の種類と枚数を求めるプログラムを書くことである。なお、店員はお釣りに紙幣を使用することはない。
		
Input

		

			入力にはいくつかのテストケースが含まれる。
		

		

			それぞれのテストケースは 2 行から構成される。 1 行目には Mr. Bill の支払い金額を円単位で表した 1 つの整数が含まれている。 2 行目には 4 つの整数が含まれており、それらは順に財布の中にある 10 円玉、50 円玉、100 円玉、500 円玉の枚数をそれぞれ表す。
		

		

			支払い金額は常に 10 円単位である。 すなわち、支払い金額の一円の位は常に 0 である。 また財布の中に、同じ種類の硬貨は最大で 20 枚までしかないと仮定してよい。 支払いが不可能なケースが入力中に与えられることはない。
		

		

			入力の終了は単一の 0 を含む行によって表される。
		

		
Output

		

			それぞれのテストケースについて、Mr. Bill が使用すべき硬貨の種類と枚数を出力せよ。
		

		

			出力の各行には 2 つの整数 ci 、ki が含まれる。これは支払いの際に ci 円玉を ki 枚使用することを意味している。
			複数種類の硬貨を使用する場合は、ci の小さいほうから順に、必要な行数だけ出力を行うこと。 下記の出力例を参考にせよ。
		

		

			なお、出力には余計なスペースを含めてはならない。 連続するテストケースの間は空行で区切ること。
		

		
Sample Input

		

160
1 1 2 0
160
1 0 2 10
0

		
Output for the Sample Input

		

10 1
50 1
100 1

10 1
100 2

1番目のデータ がある。
		

-->
		


Sample input:
160
1 1 2 0
160
1 0 2 10
0


Sample output:
10 1
50 1
100 1

10 1
100 2

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from itertools import product
coins = [10,50,100,500]

def coin_count(num):
    count = 0
    for coin in sorted(coins,reverse = True):
        count += num // coin
        num -= (num // coin)*coin
    return count

while True:
    price = int(input())
    if price == 0:
        break
    dp = [-1 for i in range(20*660)]
    dp[0] = 0
    has = map(lambda x:list(range(int(x)+1)),input().split(" "))
    ans = (10**8,())
    for t in product(*has):
        tmp = price - sum([coins[i] * t[i] for i in range(4)])
        if tmp <= 0:
            ans = min(ans,(coin_count(-1 * tmp),t))
    for i in range(4):
        if ans[1][i] != 0:
            print(coins[i],ans[1][i])
    print()

Submission status: Runtime Error

Solution code:
#! /usr/bin/python
# -*- coding: utf-8 -*-

def change(val):
    v500 = val/500
    v100 = (val-v500)/100
    v50 = (val%100)/50
    v10 = (val%50)/10
    return v10+v50+v100+v500

n = int(raw_input())
cnt = 0
while n!=0:
    if cnt > 0:
        print
    (c10, c50, c100, c500) = map(int, raw_input().split())
    Min = 1000000
    a10=0
    a50=0
    a100=0
    a500=0
    for i1 in range(c10+1):
        for i2 in range(c50+1):
            for i3 in range(c100+1):
                for i4 in range(c500+1):
                    Sumc = i1+i2+i3+i4
                    Sumv = i1*10+i2*50+i3*100+i4*500
                    if Sumv >= n:
                        Re = change(Sumv-n)
                        if Min > Re-Sumc:
                            Min = Re-Sumc
                            a10 = i1
                            a50 = i2
                            a100 = i3
                            a500 = i4
    if a10 > 0:
        print 10, a10
    if a50 > 0:
        print 50, a50
    if a100 > 0:
        print 100, a100
    if a500 > 0:
        print 500, a500
    
    n = int(raw_input())
    cnt += 1

Submission status: Runtime Error

Solution code:
def makeCahnge(c):
    money = c
    ret = []
    for i in [500, 100, 50, 10]:
        ret.append(money // i)
        money %= i
    return ret[::-1]

ansOut = []
while True:
    price = int(input())
    if price == 0: break
    c10, c50, c100, c500 = map(int, input().split())
    ans = 20*4+1
    anspay = [0, 0, 0, 0]
    for i10 in range(c10+1):
        for i50 in range(c50+1):
            for i100 in range(c100+1):
                for i500 in range(c500+1):
                    payment = sum(i*c for i, c in zip([i10, i50, i100, i500], [10, 50, 100, 500]))
                    
                    if payment >= price:
                        if sum(i-c+p for i, c, p in zip([i10, i50, i100, i500], [c10, c50, c100, c500], makeCahnge(payment - price))) < ans:
                            ans = sum(i-c+p for i, c, p in zip([i10, i50, i100, i500], [c10, c50, c100, c500], makeCahnge(payment - price))) 
                            anspay = [i10, i50, i100, i500]

    out = []
    for i, c in zip(anspay, [10, 50, 100, 500]):
        if i > 0:
            out.append('{} {}'.format(c, i))
    ansOut.append('\n'.join(out))
print('\n\n'.join(ansOut))

Submission status: Runtime Error

Solution code:
while True:
    import copy
    pay = int(input())
    if pay == 0:
        break
    else:
        num = input()
        l = num.split(' ')
        m10 = int(l[0])
        m50 = int(l[1])
        m100 = int(l[2])
        m500 = int(l[3])
        
        m10s = int(copy.deepcopy(l[0]))
        m50s = int(copy.deepcopy(l[1]))
        m100s = int(copy.deepcopy(l[2]))
        m500s = int(copy.deepcopy(l[3]))
        
        num10 = 0
        num50 = 0
        num100 = 0
        num500 = 0
        
        while pay>=500:
            if m10 >=50:
                pay -= 500
                m10 -= 50
            elif m50 >= 10:
                pay -= 500
                m50 -= 10
            elif m100 >= 5:
                pay -= 500
                m100 -= 5
            else:
                pay -= 500
                m500 -= 1
                
        while pay >= 100:
            if m10 >= 10:
                pay -= 100
                m10 -= 10
            elif m50 >= 2:
                pay -= 100
                m50 -= 2
            elif m100 >= 1:
                pay -= 100
                m100 -= 1
            else:
                pay -= 500
                m500 -= 1
                
        while pay >= 50:
            if m10 >= 5:
                pay -= 50
                m10 -= 5
            elif m50 >= 1:
                pay -= 50
                m50 -= 1
            elif m100 >= 1:
                pay -= 100
                m100 -= 1
            else:
                pay -= 500
                m500 -= 1
                
        while pay >= 10:
            if m10 >= 1:
                pay -= 10
                m10 -= 1
            elif m50 >= 1:
                pay -= 50
            elif m100 >= 1:
                pay -= 100
                m100 -= 1
            else:
                pay -= 500
                m500 -= 1
        
        m10b = 0
        m50b = 0
        m100b = 0
        m500b = 0
                
        if pay < 0:
            pay = -pay
        if pay < 50:
            m10 -= (50-pay)/10
        elif pay < 100:
            m10 -= (100-pay)/10
        elif pay < 500:
            m100 -= (500-pay)//100
            n = (500-pay)%100
            m50 -= (100-n)//50
            m = n%50
            m10 -= (50-m)/10
            
            
        num10 = m10s - m10
        num50 = m50s - m50
        num100 = m100s - m100
        num500 = m500s - m500
        
        m10 += m10b
        m100 += m100b
        m50 += m50b
        m500 += m500b
        
        while m10 >= 50:
            m10 -= 50
            num10 += 50
        while m10 >= 10:
            m10 -= 10
            num10 += 10
        while m10 >= 5:
            m10 -= 5
            num10 += 5
                
        while m50 >= 10:
            m50 -= 10
            num50 += 10
        while m50 >= 2:
            m50 -= 2
            num50 += 2
            
        while m100 >= 5:
            m100 -= 5
            num100 += 5
            
        if num10:
            print(10,int(num10)
        if num50:
            print(50,int(num50))
        if num100:
            print(100,int(num100))
        if num500:
            print(500,int(num500))
        print()

Submission status: Runtime Error

Solution code:
while True:
    import copy
    pay = int(input())
    if pay == 0:
        break
    else:
        num = input()
        l = num.split(' ')
        m10 = int(l[0])
        m50 = int(l[1])
        m100 = int(l[2])
        m500 = int(l[3])
        
        m10s = int(copy.deepcopy(l[0]))
        m50s = int(copy.deepcopy(l[1]))
        m100s = int(copy.deepcopy(l[2]))
        m500s = int(copy.deepcopy(l[3]))
        
        num10 = 0
        num50 = 0
        num100 = 0
        num500 = 0
        
        while pay>=500:
            if m10 >=50:
                pay -= 500
                m10 -= 50
            elif m50 >= 10:
                pay -= 500
                m50 -= 10
            elif m100 >= 5:
                pay -= 500
                m100 -= 5
            else:
                pay -= 500
                m500 -= 1
                
        while pay >= 100:
            if m10 >= 10:
                pay -= 100
                m10 -= 10
            elif m50 >= 2:
                pay -= 100
                m50 -= 2
            elif m100 >= 1:
                pay -= 100
                m100 -= 1
            else:
                pay -= 500
                m500 -= 1
                
        while pay >= 50:
            if m10 >= 5:
                pay -= 50
                m10 -= 5
            elif m50 >= 1:
                pay -= 50
                m50 -= 1
            elif m100 >= 1:
                pay -= 100
                m100 -= 1
            else:
                pay -= 500
                m500 -= 1
                
        while pay >= 10:
            if m10 >= 1:
                pay -= 10
                m10 -= 1
            elif m50 >= 1:
                pay -= 50
            elif m100 >= 1:
                pay -= 100
                m100 -= 1
            else:
                pay -= 500
                m500 -= 1
        
        m10b = 0
        m50b = 0
        m100b = 0
        m500b = 0
                
        if pay < 0:
            pay = -pay
        if pay < 50:
            m10 -= (50-pay)/10
        elif pay < 100:
            m10 -= (100-pay)/10
        elif pay < 500:
            m100 -= (500-pay)//100
            n = (500-pay)%100
            m50 -= (100-n)//50
            m = n%50
            m10 -= (50-m)/10
            
            
        num10 = m10s - m10
        num50 = m50s - m50
        num100 = m100s - m100
        num500 = m500s - m500
        
        m10 += m10b
        m100 += m100b
        m50 += m50b
        m500 += m500b
        
        while m10 >= 50:
            m10 -= 50
            num10 += 50
        while m10 >= 10:
            m10 -= 10
            num10 += 10
        while m10 >= 5:
            m10 -= 5
            num10 += 5
                
        while m50 >= 10:
            m50 -= 10
            num50 += 10
        while m50 >= 2:
            m50 -= 2
            num50 += 2
            
        while m100 >= 5:
            m100 -= 5
            num100 += 5
            
        if num10!=0:
            print(10,int(num10))
        if num50!=0:
            print(50,int(num50))
        if num100!=0:
            print(100,int(num100))
        if num500!=0:
            print(500,int(num500))
        print()

Submission status: Runtime Error

Solution code:
while True:
    import copy
    pay = int(input())
    if pay == 0:
        break
    else:
        num = input()
        l = num.split(' ')
        m10 = int(l[0])
        m50 = int(l[1])
        m100 = int(l[2])
        m500 = int(l[3])
        
        m10s = int(copy.deepcopy(l[0]))
        m50s = int(copy.deepcopy(l[1]))
        m100s = int(copy.deepcopy(l[2]))
        m500s = int(copy.deepcopy(l[3]))
        
        num10 = 0
        num50 = 0
        num100 = 0
        num500 = 0
        
        while pay>=500:
            if m10 >=50:
                pay -= 500
                m10 -= 50
            elif m50 >= 10:
                pay -= 500
                m50 -= 10
            elif m100 >= 5:
                pay -= 500
                m100 -= 5
            else:
                pay -= 500
                m500 -= 1
                
        while pay >= 100:
            if m10 >= 10:
                pay -= 100
                m10 -= 10
            elif m50 >= 2:
                pay -= 100
                m50 -= 2
            elif m100 >= 1:
                pay -= 100
                m100 -= 1
            else:
                pay -= 500
                m500 -= 1
                
        while pay >= 50:
            if m10 >= 5:
                pay -= 50
                m10 -= 5
            elif m50 >= 1:
                pay -= 50
                m50 -= 1
            elif m100 >= 1:
                pay -= 100
                m100 -= 1
            else:
                pay -= 500
                m500 -= 1
                
        while pay >= 10:
            if m10 >= 1:
                pay -= 10
                m10 -= 1
            elif m50 >= 1:
                pay -= 50
            elif m100 >= 1:
                pay -= 100
                m100 -= 1
            else:
                pay -= 500
                m500 -= 1
        
        m10b = 0
        m50b = 0
        m100b = 0
        m500b = 0
                
        if pay < 0:
            pay = -pay
        if 0 < pay and pay < 50:
            m10 -= (50-pay)/10
        elif 50 < pay and pay < 100:
            m10 -= (100-pay)/10
        elif 100 < pay and pay < 500:
            m100 -= (500-pay)//100
            n = (500-pay)%100
            m50 -= (100-n)//50
            m = n%50
            m10 -= (50-m)/10
            
            
        num10 = m10s - m10
        num50 = m50s - m50
        num100 = m100s - m100
        num500 = m500s - m500
        
        m10 += m10b
        m100 += m100b
        m50 += m50b
        m500 += m500b
        
        while m10 >= 50:
            m10 -= 50
            num10 += 50
        while m10 >= 10:
            m10 -= 10
            num10 += 10
        while m10 >= 5:
            m10 -= 5
            num10 += 5
                
        while m50 >= 10:
            m50 -= 10
            num50 += 10
        while m50 >= 2:
            m50 -= 2
            num50 += 2
            
        while m100 >= 5:
            m100 -= 5
            num100 += 5
            
        if num10!=0:
            print(10,int(num10))
        if num50!=0:
            print(50,int(num50))
        if num100!=0:
            print(100,int(num100))
        if num500!=0:
            print(500,int(num500))
        print()

Submission status: Runtime Error

Solution code:

def back_oturigation(fee, coin_values, coin_nums):
    """
    1. ????????????????????????????????£??????????????????
    2. 1????????????????????????????????????????????????????????????
       ???????????§?????????????????????-> ?°????????????????????¶???????????????????
    3. 2????????????????????°?????????????????????????????????????????????
    """
    # 1.
    oturi = coin_values[0]*coin_nums[0]\
            +coin_values[1]*coin_nums[1]\
            +coin_values[2]*coin_nums[2]\
            +coin_values[3]*coin_nums[3]\
            -fee
    use_coins = [0] * len(coin_value)
    no_use_coins = [0]*len(coin_value)

    # 2.
    for i in range(len(coin_value)-1, -1, -1):
        print(coin_value[i])
        import pdb;pdb.set_trace()

        no_use_coins[i] = int(oturi / coin_value[i])
        oturi = oturi - (coin_value[i] * no_use_coins[i])


    #3.
    for i in range(0, len(use_coins), 1):
        use_coins[i] = coin_nums[i] - no_use_coins[i]
        if use_coins[i] > 0:
            print(coin_value[i],' ',use_coins[i])

if __name__ == "__main__":
    total_fee = int(input('total_fee:'))
    coins = input('total_coins:')
    coins = coins.split(' ') #10, 50, 100, 500????????§????????????
    coins = [int(coin) for coin in coins]
    coin_value=[10, 50, 100, 500]
    back_oturigation(total_fee, coin_value, coins)

Submission status: Runtime Error

Solution code:

def back_oturigation(fee, coin_values, coin_nums):
    """
    1. ????????????????????????????????£??????????????????
    2. 1????????????????????????????????????????????????????????????
       ???????????§?????????????????????-> ?°????????????????????¶???????????????????
    3. 2????????????????????°?????????????????????????????????????????????
    """
    # 1.
    oturi = coin_values[0]*coin_nums[0]\
            +coin_values[1]*coin_nums[1]\
            +coin_values[2]*coin_nums[2]\
            +coin_values[3]*coin_nums[3]\
            -fee
    use_coins = [0] * len(coin_values)
    no_use_coins = [0]*len(coin_values)

    # 2.
    for i in range(len(coin_values)-1, -1, -1):
        no_use_coins[i] = int(oturi / coin_values[i])
        oturi = oturi - (coin_values[i] * no_use_coins[i])


    #3.
    result = ""
    for i in range(0, len(use_coins), 1):
        use_coins[i] = coin_nums[i] - no_use_coins[i]
        if use_coins[i] > 0:
            print(str(coin_values[i]) + ' ' + str(use_coins[i]))
            result = result+str(coin_values[i]) + ' ' + str(use_coins[i])+'\n'
    return result

if __name__ == "__main__":

    #check_testcase()
    total_fee = int(input('total_fee:'))

    while(True):
        if total_fee == 0:break
        coins = input('total_coins:')
        coins = coins.split(' ') #10, 50, 100, 500????????§????????????
        coins = [int(coin) for coin in coins]
        coin_values=[10, 50, 100, 500]
        back_oturigation(total_fee, coin_values, coins)

Submission status: Runtime Error

Solution code:
def back_oturigation(fee, coin_values, coin_nums):
    """
    1. ????????????????????????????????£??????????????????
    2. 1????????????????????????????????????????????????????????????
       ???????????§?????????????????????-> ?°????????????????????¶???????????????????
    3. 2????????????????????°?????????????????????????????????????????????
    """
    # 1.
    oturi = coin_values[0]*coin_nums[0]\
            +coin_values[1]*coin_nums[1]\
            +coin_values[2]*coin_nums[2]\
            +coin_values[3]*coin_nums[3]\
            -fee
    use_coins = [0] * len(coin_values)
    no_use_coins = [0]*len(coin_values)

    # 2.
    for i in range(len(coin_values)-1, -1, -1):
        no_use_coins[i] = int(oturi / coin_values[i])
        oturi = oturi - (coin_values[i] * no_use_coins[i])


    #3.
    result = ""
    for i in range(0, len(use_coins), 1):
        use_coins[i] = coin_nums[i] - no_use_coins[i]
        if use_coins[i] > 0:
            print(str(coin_values[i]) + ' ' + str(use_coins[i]))
            result = result+str(coin_values[i]) + ' ' + str(use_coins[i])+'\n'
    #return result

if __name__ == "__main__":

    #check_testcase()
    total_fee = int(input('total_fee:'))

    while(True):
        if total_fee == 0:break
        coins = input('total_coins:')
        coins = coins.split(' ') #10, 50, 100, 500????????§????????????
        coins = [int(coin) for coin in coins]
        coin_values=[10, 50, 100, 500]
        back_oturigation(total_fee, coin_values, coins)

Submission status: Runtime Error

Solution code:
def back_oturigation(fee, coin_values, coin_nums):
    """
    1. ????????????????????????????????£??????????????????
    2. 1????????????????????????????????????????????????????????????
       ???????????§?????????????????????-> ?°????????????????????¶???????????????????
    3. 2????????????????????°?????????????????????????????????????????????
    """
    # 1.
    oturi = coin_values[0]*coin_nums[0]\
            +coin_values[1]*coin_nums[1]\
            +coin_values[2]*coin_nums[2]\
            +coin_values[3]*coin_nums[3]\
            -fee
    use_coins = [0] * len(coin_values)
    no_use_coins = [0]*len(coin_values)

    # 2.
    for i in range(len(coin_values)-1, -1, -1):
        no_use_coins[i] = int(oturi / coin_values[i])
        oturi = oturi - (coin_values[i] * no_use_coins[i])


    #3.
    result = ""
    for i in range(0, len(use_coins), 1):
        use_coins[i] = coin_nums[i] - no_use_coins[i]
        if use_coins[i] > 0:
            print(str(coin_values[i]) + ' ' + str(use_coins[i]))
            result = result+str(coin_values[i]) + ' ' + str(use_coins[i])+'\n'
    #return result

if __name__ == "__main__":
    total_fee = int(input('total_fee:'))
    while(True):
        if total_fee == 0:break
        coins = input('total_coins:')
        coins = coins.split(' ') #10, 50, 100, 500????????§????????????
        coins = [int(coin) for coin in coins]
        coin_values=[10, 50, 100, 500]
        back_oturigation(total_fee, coin_values, coins)

Submission status: Runtime Error

Solution code:
def back_oturigation(fee, coin_values, coin_nums):
    """
    1. ????????????????????????????????£??????????????????
    2. 1????????????????????????????????????????????????????????????
       ???????????§?????????????????????-> ?°????????????????????¶???????????????????
    3. 2????????????????????°?????????????????????????????????????????????
    """
    # 1.
    oturi = coin_values[0] * coin_nums[0] \
            + coin_values[1] * coin_nums[1] \
            + coin_values[2] * coin_nums[2] \
            + coin_values[3] * coin_nums[3] \
            - fee
    use_coins = [0] * len(coin_values)
    no_use_coins = [0] * len(coin_values)

    # 2.
    for i in range(len(coin_values) - 1, -1, -1):
        no_use_coins[i] = int(oturi / coin_values[i])
        oturi = oturi - (coin_values[i] * no_use_coins[i])

    # 3.
    result = ''
    for i in range(0, len(use_coins), 1):
        use_coins[i] = coin_nums[i] - no_use_coins[i]
        if use_coins[i] > 0:
            print(str(coin_values[i]) + ' ' + str(use_coins[i]))
            result = result + str(coin_values[i]) + ' ' + str(use_coins[i]) + '\n'
            # return result


if __name__ == "__main__":

    # check_testcase()
    total_fee = int(input('total_fee:'))

    while (True):
        if total_fee == 0: break
        coins = input('total_coins:')
        coins = coins.split(' ')  # 10, 50, 100, 500????????§????????????
        coins = [int(coin) for coin in coins]
        coin_values = [10, 50, 100, 500]
        back_oturigation(total_fee, coin_values, coins)

Submission status: Runtime Error

Solution code:
def back_oturigation(fee, coin_values, coin_nums):
    """
    1. ????????????????????????????????£??????????????????
    2. 1????????????????????????????????????????????????????????????
       ???????????§?????????????????????-> ?°????????????????????¶???????????????????
    3. 2????????????????????°?????????????????????????????????????????????
    """
    # 1.
    oturi = coin_values[0] * coin_nums[0] \
            + coin_values[1] * coin_nums[1] \
            + coin_values[2] * coin_nums[2] \
            + coin_values[3] * coin_nums[3] \
            - fee
    use_coins = [0] * len(coin_values)
    no_use_coins = [0] * len(coin_values)

    # 2.
    for i in range(len(coin_values) - 1, -1, -1):
        no_use_coins[i] = int(oturi / coin_values[i])
        oturi = oturi - (coin_values[i] * no_use_coins[i])

    # 3.
    result = ''
    for i in range(0, len(use_coins), 1):
        use_coins[i] = coin_nums[i] - no_use_coins[i]
        if use_coins[i] > 0:
            print(str(coin_values[i]) + ' ' + str(use_coins[i]))
            # result = result + str(coin_values[i]) + ' ' + str(use_coins[i]) + '\n'
            # return result


if __name__ == "__main__":

    # check_testcase()
    total_fee = int(input('total_fee:'))

    while (True):
        if total_fee == 0: break
        coins = input('total_coins:')
        coins = coins.split(' ')  # 10, 50, 100, 500????????§????????????
        coins = [int(coin) for coin in coins]
        coin_values = [10, 50, 100, 500]
        back_oturigation(total_fee, coin_values, coins)

Submission status: Runtime Error

Solution code:
def back_oturigation(fee, coin_values, coin_nums):
    """
    1. ????????????????????????????????£??????????????????
    2. 1????????????????????????????????????????????????????????????
       ???????????§?????????????????????-> ?°????????????????????¶???????????????????
    3. 2????????????????????°?????????????????????????????????????????????
    """
    # 1.
    oturi = coin_values[0] * coin_nums[0] \
            + coin_values[1] * coin_nums[1] \
            + coin_values[2] * coin_nums[2] \
            + coin_values[3] * coin_nums[3] \
            - fee
    use_coins = [0] * len(coin_values)
    no_use_coins = [0] * len(coin_values)

    # 2.
    for i in range(len(coin_values) - 1, -1, -1):
        no_use_coins[i] = int(oturi / coin_values[i])
        oturi = oturi - (coin_values[i] * no_use_coins[i])

    # 3.
    result = ''
    for i in range(0, len(use_coins), 1):
        use_coins[i] = coin_nums[i] - no_use_coins[i]
        if use_coins[i] > 0:
            print(str(coin_values[i]) + ' ' + str(use_coins[i]))
            # result = result + str(coin_values[i]) + ' ' + str(use_coins[i]) + '\n'
            # return result

if __name__ == "__main__":
    total_fee = int(input('total_fee:'))

    while (total_fee != 0):
        coins = input('total_coins:')
        coins = coins.split(' ')  # 10, 50, 100, 500????????§????????????
        coins = [int(coin) for coin in coins]
        coin_values = [10, 50, 100, 500]
        back_oturigation(total_fee, coin_values, coins)

Submission status: Runtime Error

Solution code:
def back_oturigation(fee, coin_values, coin_nums):
    oturi = coin_values[0] * coin_nums[0] \
            + coin_values[1] * coin_nums[1] \
            + coin_values[2] * coin_nums[2] \
            + coin_values[3] * coin_nums[3] \
            - fee
    use_coins = [0] * len(coin_values)
    no_use_coins = [0] * len(coin_values)


    for i in range(len(coin_values) - 1, -1, -1):
        no_use_coins[i] = int(oturi / coin_values[i])
        oturi = oturi - (coin_values[i] * no_use_coins[i])


    for i in range(0, len(use_coins), 1):
        use_coins[i] = coin_nums[i] - no_use_coins[i]
        if use_coins[i] > 0:
            print(str(coin_values[i]) + ' ' + str(use_coins[i]))


if __name__ == "__main__":
    total_fee = int(input('total_fee:'))

    while (total_fee != 0):
        coins = input('total_coins:')
        coins = coins.split(' ')  # 10, 50, 100, 500????????§????????????
        coins = [int(coin) for coin in coins]
        coin_values = [10, 50, 100, 500]
        back_oturigation(total_fee, coin_values, coins)

Submission status: Runtime Error

Solution code:


def back_oturigation(fee, coin_values, coin_nums):
    """
    1. ????????????????????????????????£??????????????????
    2. 1????????????????????????????????????????????????????????????
       ???????????§?????????????????????-> ?°????????????????????¶???????????????????
    3. 2????????????????????°?????????????????????????????????????????????
    """
    # 1.
    oturi = coin_values[0] * coin_nums[0] \
            + coin_values[1] * coin_nums[1] \
            + coin_values[2] * coin_nums[2] \
            + coin_values[3] * coin_nums[3] \
            - fee
    use_coins = [0] * len(coin_values)
    no_use_coins = [0] * len(coin_values)

    # 2.
    for i in range(len(coin_values) - 1, -1, -1):
        no_use_coins[i] = int(oturi / coin_values[i])
        oturi = oturi - (coin_values[i] * no_use_coins[i])

    # 3.
    for i in range(0, len(use_coins), 1):
        use_coins[i] = coin_nums[i] - no_use_coins[i]
        if use_coins[i] > 0:
            print(str(coin_values[i]) + ' ' + str(use_coins[i]))

if __name__ == "__main__":
    total_fee = int(input('total_fee:'))

    while (total_fee != 0):
        coins = input('total_coins:')
        coins = coins.split(' ')  # 10, 50, 100, 500????????§????????????
        coins = [int(coin) for coin in coins]
        coin_values = [10, 50, 100, 500]
        back_oturigation(total_fee, coin_values, coins)

Submission status: Runtime Error

Solution code:
# http://www.deqnotes.net/acmicpc/p0006/
def back_oturigation(fee, coin_values, coin_nums):
    """
    1. ????????????????????????????????£??????????????????
    2. 1????????????????????????????????????????????????????????????
       ???????????§?????????????????????-> ?°????????????????????¶???????????????????
    3. 2????????????????????°?????????????????????????????????????????????
    """
    # 1.
    oturi = coin_values[0] * coin_nums[0] \
            + coin_values[1] * coin_nums[1] \
            + coin_values[2] * coin_nums[2] \
            + coin_values[3] * coin_nums[3] \
            - fee
    use_coins = [0] * len(coin_values)
    no_use_coins = [0] * len(coin_values)

    # 2.
    for i in range(len(coin_values) - 1, -1, -1):
        no_use_coins[i] = int(oturi / coin_values[i])
        oturi = oturi - (coin_values[i] * no_use_coins[i])

    # 3.
    for i in range(0, len(use_coins), 1):
        use_coins[i] = coin_nums[i] - no_use_coins[i]
        if use_coins[i] > 0:
            print(str(coin_values[i]) + ' ' + str(use_coins[i]))

if __name__ == "__main__":
    total_fee = int(input('total_fee:'))

    while (total_fee != 0):
        coins = input('total_coins:')
        coins = coins.split(' ')  # 10, 50, 100, 500????????§????????????
        coins = [int(coin) for coin in coins]
        coin_values = [10, 50, 100, 500]
        back_oturigation(total_fee, coin_values, coins)

Submission status: Runtime Error

Solution code:
def back_oturigation(fee, coin_values, coin_nums):
    """
    1. ????????????????????????????????£??????????????????
    2. 1????????????????????????????????????????????????????????????
       ???????????§?????????????????????-> ?°????????????????????¶???????????????????
    3. 2????????????????????°?????????????????????????????????????????????
    """
    # 1.
    oturi = coin_values[0] * coin_nums[0] \
            + coin_values[1] * coin_nums[1] \
            + coin_values[2] * coin_nums[2] \
            + coin_values[3] * coin_nums[3] \
            - fee
    use_coins = [0] * len(coin_value)
    no_use_coins = [0] * len(coin_value)

    # 2.
    for i in range(len(coin_value) - 1, -1, -1):
        no_use_coins[i] = int(oturi / coin_value[i])
        oturi = oturi - (coin_value[i] * no_use_coins[i])

    # 3.
    for i in range(0, len(use_coins), 1):
        use_coins[i] = coin_nums[i] - no_use_coins[i]
        if use_coins[i] > 0:
            print(str(coin_value[i]) + ' ' + str(use_coins[i]))

if __name__ == "__main__":
    total_fee = int(input('total_fee:'))

    while (total_fee != 0):
        coins = input('total_coins:')
        coins = coins.split(' ')  # 10, 50, 100, 500????????§????????????
        coins = [int(coin) for coin in coins]
        coin_value = [10, 50, 100, 500]
        back_oturigation(total_fee, coin_value, coins)