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.
32 lines
588 B
32 lines
588 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
int n, m;
|
|
vector<int> a;
|
|
int sum;
|
|
int cnt;
|
|
|
|
void dfs(int step, int start) {
|
|
if (step == n + 1) {
|
|
if (sum == m) {
|
|
for (int i = 0; i < a.size(); i++) printf("%d ", a[i]);
|
|
printf("\n");
|
|
cnt++;
|
|
}
|
|
return;
|
|
}
|
|
for (int i = start; i < m; i++) {
|
|
a.push_back(i);
|
|
sum += i;
|
|
dfs(step + 1, i);
|
|
sum -= i;
|
|
a.pop_back();
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
cin >> n >> m;
|
|
dfs(1, 1);
|
|
printf("%d", cnt);
|
|
return 0;
|
|
} |