Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. long long cash, coinNumber;
  8. cin>>cash>>coinNumber;
  9. long long dp[cash+1];
  10. memset(dp, 0, sizeof(long long)*(cash+1));
  11. dp[0]=1;
  12. int coins[coinNumber];
  13. for(int x=0; x<coinNumber; x++){
  14. cin>>coins[x];
  15. }
  16. for(int y=0; y<coinNumber; y++){
  17. for(int x=0; x<cash; x++){
  18. if((coins[y]+x)<=cash){
  19. dp[coins[y]+x]+=dp[x];
  20. }
  21. }
  22. }
  23. cout<<dp[cash];
  24.  
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement