You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
512 B
30 lines
512 B
#include <iostream>
|
|
|
|
using namespace std;
|
|
int n, m;
|
|
const int N = 110;
|
|
int res;
|
|
int a[N];
|
|
|
|
void dfs(int u) {
|
|
if (u == n + 1) {
|
|
int sum = 0;
|
|
for (int i = 1; i <= n; i++) sum += a[i];
|
|
if (sum == m) {
|
|
res++;
|
|
}
|
|
return;
|
|
}
|
|
for (int i = a[u - 1]; i >= 1; i--) {
|
|
a[u] += i;
|
|
dfs(u + 1);
|
|
a[u] -= i;
|
|
}
|
|
}
|
|
int main() {
|
|
cin >> n >> m;
|
|
a[0] = m;
|
|
dfs(1);
|
|
cout << res << endl;
|
|
return 0;
|
|
} |