Advertisement
Saleh127

UVA 357

Nov 17th, 2020
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. ll dp[30005];
  6. int main()
  7. {
  8. ios_base::sync_with_stdio(0);
  9. cin.tie(0);
  10. cout.tie(0);
  11.  
  12. ll coin[]= {1, 5, 10, 25, 50};
  13. dp[0]=1;
  14. for(ll i=0; i<5; i++)
  15. {
  16. for(ll j=coin[i]; j<=30000; j++)
  17. {
  18. dp[j]+=dp[j-coin[i]];
  19. }
  20. }
  21. ll n;
  22.  
  23. while(scanf("%lld",&n)==1)
  24. {
  25. if(dp[n]==1) printf("There is only 1 way to produce %lld cents change.\n",n);
  26. else printf("There are %lld ways to produce %lld cents change.\n",dp[n],n);
  27. }
  28.  
  29. return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement