Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "bits/stdc++.h"
- using namespace std;
- int main()
- {
- int n, sum = 0;
- int money[6];
- int money_price[6]= {100,50,20,10,5,1};
- int can = 0;
- bool f = 0;
- freopen("input.txt","r",stdin);
- freopen("output.txt", "w", stdout);
- cin>>n;
- for(int i = 0; i < 6; i++){
- cin>>money[i];
- }
- for(int i = 0; i < 6; i++){
- for(int j = 1; j <= money[i]; j++){
- sum += money_price[i];
- can += 1;
- }
- if(sum == 1000 - n){
- f = 1;
- break;
- }
- cout<<sum<<endl;
- }
- if(f)
- cout<<can;
- else
- cout<<"No solution";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement