-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path10313.cpp
More file actions
39 lines (26 loc) · 687 Bytes
/
10313.cpp
File metadata and controls
39 lines (26 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
using namespace std;
// ammount, ncoins
int dp[301][301], ammount, ncoins;
int nways(int val, int nc) {
if (nc == 1) return 1;
if (val == 0) return 1;
int ways = 0;
for (int i = 1; i <= val; i++)
ways += nways(val-i, nc-1);
cout << val << ' ' << nc << ' ' << ways << endl;
return ways;
}
int main() {
while (cin >> ammount) {
for (int i = 1; i <= ammount; i++)
for (int j = 1; j <= ammount; j++)
dp[i][j] = 0;
for (int i = 0; i <= ammount; i++) dp[0][i] = 1;
for (int i = 1; i <= ammount; i++)
for (int j = 1; j <= i; j++)
dp[i][j] += dp[
cout << nways(ammount, 6) << endl;
}
return 0;
}