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.
1 parent 9b72dd6 commit 84a6584Copy full SHA for 84a6584
Hackerrank/Problem Solving/CoinExchangeProblem
@@ -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