fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4. const int MAXN = 1e6+10;
  5. const int MOD = 1e9+7;
  6.  
  7. int main()
  8. {
  9. ios_base::sync_with_stdio(false);
  10. cin.tie(0);cout.tie(0);
  11. int n;
  12. cin >> n;
  13. vector<int> v = {1,2,5,10,20,50,100,200,500,1000};
  14. int res(0);
  15. for(int i=9;i>=0;i--)
  16. {
  17. res+=(n/v[i]);
  18. n%=v[i];
  19. }
  20. cout << res;
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0.01s 5304KB
stdin
Standard input is empty
stdout
28