Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- long long cash, coinNumber;
- cin>>cash>>coinNumber;
- long long dp[cash+1];
- memset(dp, 0, sizeof(long long)*(cash+1));
- dp[0]=1;
- int coins[coinNumber];
- for(int x=0; x<coinNumber; x++){
- cin>>coins[x];
- }
- for(int y=0; y<coinNumber; y++){
- for(int x=0; x<cash; x++){
- if((coins[y]+x)<=cash){
- dp[coins[y]+x]+=dp[x];
- }
- }
- }
- cout<<dp[cash];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement