n = int(input())
kup = 0
while n != 0:
if n-500 >= 0:
n-=500
kup += 1
while n != 0:
if n-500 >= 0:
kup += 1
else: break
elif n-200 >= 0:
kup += 1
n-= 200
while n != 0:
if n-200 >= 0:
kup += 1
n-=200
else: break
elif n-100 >= 0:
kup += 1
n-= 100
while n != 0:
if n-100 == 0:
kup += 1
n-=100
else: break
elif n-50 >= 0:
kup += 1
n-= 50
while n != 0:
if n-50 >= 0:
kup += 1
n-=50
else: break
elif n-20 == 0:
kup += 1
n-= 20
while n != 0:
if n-20 >= 0:
kup += 1
n-=20
else: break
elif n-10 == 0:
kup += 1
n-= 10
while n != 0:
if n-10 >= 0:
kup += 1
n-=10
else: break
elif n-5 == 0:
kup += 1
n-= 5
while n != 0:
if n-5 >= 0:
kup += 1
n-=5
else: break
elif n-2 == 0:
kup += 1
n-= 2
while n != 0:
if n-2 >= 0:
kup += 1
n-=2
else: break
elif n-1 == 0:
kup += 1
n-= 1
while n != 0:
if n-1 >= 0:
kup += 1
n-=1
else: break
print(kup)
from enum import Enum
class Banknotes(Enum):
ONE = 1
TWO = 2
FIVE = 5
TEN = 10
TWENTY = 20
FIFTY = 50
ONE_HUNDRED = 100
TWO_HUNDRED = 200
FIVE_HUNDRED = 500
ONE_THOUSAND = 1000
def get_min_count_banknotes(amount: int) -> dict:
all_banknotes = {}
for b in reversed(Banknotes):
all_banknotes[b.name] = 0
while amount // b.value > 0:
all_banknotes[b.name] += 1
amount -= b.value
banknotes = {banknote: count for banknote, count in all_banknotes.items() if count != 0}
return banknotes
def get_total_count_banknotes(amount: int) -> int:
ret = get_min_count_banknotes(amount)
count = sum(ret.values())
return count
if __name__ == '__main__':
# n = int(input('Введите сумму'))
n = 1234
b_notes = get_min_count_banknotes(n)
for k, v in b_notes.items():
print(f'Купюра - {k} , количество - {v}')
cnt_b_notes = get_total_count_banknotes(n)
print(f'Всего купюр - {cnt_b_notes}')
# Купюра - ONE_THOUSAND, количество - 1
# Купюра - TWO_HUNDRED, количество - 1
# Купюра - TWENTY, количество - 1
# Купюра - TEN, количество - 1
# Купюра - TWO, количество - 2
# Всего купюр - 6