fork download
  1. x = 123
  2. y = 1000
  3. d = y-x
  4. coin = [0,0,0,0,0,0]
  5.  
  6. while d!=0:
  7. if d >= 500:
  8. coin[0] += 1
  9. d = d-500
  10. elif d >= 100:
  11. coin[1] += 1
  12. d = d-100
  13. elif d >= 50:
  14. coin[2] += 1
  15. d = d-50
  16. elif d >= 10:
  17. coin[3] += 1
  18. d = d-10
  19. elif d >= 5:
  20. coin[4] += 1
  21. d = d-5
  22. elif d >= 1:
  23. coin[5] += 1
  24. d = d-1
  25.  
  26. print('500 x {}'.format(coin[0]))
  27. print('100 x {}'.format(coin[1]))
  28. print('50 x {}'.format(coin[2]))
  29. print('10 x {}'.format(coin[3]))
  30. print('5 x {}'.format(coin[4]))
  31. print('1 x {}'.format(coin[5]))
Success #stdin #stdout 0.02s 9096KB
stdin
Standard input is empty
stdout
500 x 1
100 x 3
50 x 1
10 x 2
5 x 1
1 x 2