voiddfs(int u, int state){ if (u == a) { for (int i = 0; i < a; i++) if (state >> i & 1) cout << i + 1 << ' '; cout << endl; return; } dfs(u + 1, state); dfs(u + 1, state | 1 << u);
voiddfs(int u, int sum, int state){ if (sum + n - u < m) return; if (sum == m) { for (int i = 0; i < n; i++) if (state >> i & 1) cout << i + 1 << ' '; cout << endl; return; } dfs(u + 1, sum + 1, state | 1 << u); dfs(u + 1, sum , state); }
intmain(){ cin >> n >> m; dfs(0, 0, 0); return0; }