Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
2901
1827
Lưu ý: Vì chỉ có 3 loại là 500, 200, 100 nên phải nhập n là số tròn trăm nó mới tính ra chính xác được.
Code Python:
from collections import defaultdict
n = int(input('n = '))
m = n
res = defaultdict(lambda: 0)
cres = 0
for i in (500, 200, 100):
while (n >= i):
n -= i
res[i] += 1
cres += 1
print(m, 'doi ra:')
print(res[500], 'to 500')
print(res[200], 'to 200')
print(res[100], 'to 100')
print('Tong:', cres,'to tien')
$\\$
`\bb\text{@Daoanhviet96}`
Hãy giúp mọi người biết câu trả lời này thế nào?
Bảng tin