Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void input(int count, vector<int> v) {
  5.  
  6. for (int i = 0;i < count;i++)
  7. {
  8. int in;
  9. cin >> in;
  10. v.push_back(in);
  11. }
  12. }
  13.  
  14. int mod(int n, int target, int current, int count)
  15. {
  16.  
  17. while (n % target != 0)
  18. {
  19. n -= current;
  20. count++;
  21. }
  22. if (target == 5)
  23. {
  24. return mod(n, 10, 5, count);
  25. }
  26. else if (target == 10)
  27. {
  28. return mod(n, 20, 10, count);
  29. }
  30. else if (target == 20)
  31. {
  32. return mod(n, 100, 20, count);
  33. }
  34. else
  35. {
  36. count = count + n / 100;
  37. return count;
  38. }
  39.  
  40. }
  41.  
  42. int main()
  43. {
  44. int n;
  45. cin >> n;
  46. int c = mod(n, 5, 1, 0);
  47. cout << c;
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement