Skip to content

Commit 6a115b7

Browse files
authored
Merge pull request larissalages#65 from Kartik987/patch-1
CoinExchangeProblem.cpp
2 parents 6b3c6b2 + 4366354 commit 6a115b7

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
long getWays(long n, vector < long > c){
6+
long m=c.size();
7+
long count[n+1];
8+
memset(count, 0, sizeof(count));
9+
10+
count[0] = 1;
11+
12+
13+
for (int i=1; i<=n; i++)
14+
for (int j=0; j<m; j++)
15+
16+
17+
if (i >= c[j])
18+
count[i] += count[i] - c[j];
19+
20+
return count[n];
21+
22+
}
23+
24+
int main() {
25+
int n;
26+
int m;
27+
cin >> n >> m;
28+
vector<long> c(m);
29+
for(int c_i = 0; c_i < m; c_i++){
30+
cin >> c[c_i];
31+
}
32+
long ways = getWays(n, c);
33+
return 0;
34+
}

0 commit comments

Comments
 (0)