Leeee1111 / testjudge-asia

0 stars 0 forks source link

B0202 找零錢問題 #9

Open Leeee1111 opened 1 month ago

Leeee1111 commented 1 month ago
def give_change(change):
    d=change//10
    change%=10
    e=change//5
    change%=5
    print(change,e,d,sep="\n")
    return 0
a=list(map(int, input().split()))

b=a[1]*15+a[2]*5+a[3]*13
if b>a[0]:
    print("0")
else:
    c=a[0]-b
    give_change(c)
Leeee1111 commented 1 month ago
def calculate_change(total, small, medium, large):
    cost = small * 15 + medium * 5 + large * 13
    if cost > total:
        return "0"

    change = total - cost
    dollars = change // 10
    change %= 10
    nickels = change // 5
    pennies = change % 5

    return f"{pennies}\n{nickels}\n{dollars}"

total, small, medium, large = map(int, input().split())

print(calculate_change(total, small, medium, large))