Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include "bits/stdc++.h"
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n, sum = 0;
  8. int money[6];
  9. int money_price[6]= {100,50,20,10,5,1};
  10. int can = 0;
  11. bool f = 0;
  12. freopen("input.txt","r",stdin);
  13. freopen("output.txt", "w", stdout);
  14. cin>>n;
  15.  
  16. for(int i = 0; i < 6; i++){
  17. cin>>money[i];
  18. }
  19. for(int i = 0; i < 6; i++){
  20. for(int j = 1; j <= money[i]; j++){
  21. sum += money_price[i];
  22. can += 1;
  23. }
  24. if(sum == 1000 - n){
  25. f = 1;
  26. break;
  27. }
  28. cout<<sum<<endl;
  29. }
  30. if(f)
  31. cout<<can;
  32. else
  33. cout<<"No solution";
  34.  
  35.  
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement