fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3.  
  4. using namespace std;
  5.  
  6.  
  7.  
  8. int main() {
  9. int t = 1; cin >> t;
  10. vector<int> v = {1, 2, 5, 10, 20, 50, 100, 200, 500, 1000};
  11. while (t--) {
  12. int n; cin >> n;
  13. int i = v.size() - 1;
  14. int cnt = 0;
  15. while(n != 0){
  16. cnt += n / v[i];
  17. n %= v[i];
  18. i--;
  19. }
  20. cout << cnt << endl;
  21. }
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
11