fork(1) download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. int main() {
  7. int s, n;
  8. cin >> s >> n;
  9. vector<int> cmd(s,0);
  10. cmd.resize(s+n-1,1);
  11. do {
  12. vector<int> answer(n,0);
  13. int where = 0;
  14. for (int c : cmd) if (c) ++where; else ++answer[where];
  15. for (int x : answer) cout << x << " "; cout << endl;
  16. } while (next_permutation(cmd.begin(),cmd.end()));
  17. }
Success #stdin #stdout 0s 15240KB
stdin
3 3
stdout
3 0 0 
2 1 0 
2 0 1 
1 2 0 
1 1 1 
1 0 2 
0 3 0 
0 2 1 
0 1 2 
0 0 3