fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4. int n;
  5. void print(vector<int>b){
  6. for (int it:b)
  7. cout << it;
  8. cout << '\n';
  9. }
  10. void bin(vector<int>a, int i)
  11. {
  12. if (i == n)
  13. {
  14. print(a);
  15. return;
  16. }
  17. a.push_back(0);
  18. bin(a, i + 1);
  19. a.pop_back();
  20. a.push_back(1);
  21. bin(a, i + 1);
  22. }
  23.  
  24. int main() {
  25. ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  26. int t;
  27. cin>>t;
  28. while(t--) {
  29. cin>>n;
  30. vector<int> arr;
  31. arr.clear();
  32. bin(arr, 0);
  33. }
  34. }
Success #stdin #stdout 0.01s 5472KB
stdin
1
3
stdout
000
001
010
011
100
101
110
111