We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 6b3c6b2 + 4366354 commit 6a115b7Copy full SHA for 6a115b7
Hackerrank/Problem Solving/CoinExchangeProblem.cpp
@@ -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