fork download
  1. #include<bits/stdc++.h>
  2. // #define int long long
  3. #define f1(i, n) for(int i=1;i<=n;++i)
  4. #define f0(i, n) for(int i=0;i<n;i++)
  5. #define all(x) x.begin(), x.end()
  6. #define fi first
  7. #define se second
  8. #define pb push_back
  9. #define endl "\n"
  10. #define NAME "countpath"
  11. using namespace std;
  12.  
  13. const int MAXN = 1e3 + 5;
  14. const int maxRC = 2207;
  15. const int MOD = 998244353;
  16.  
  17. int n;
  18. int bin[30];
  19.  
  20. void Try(int i) {
  21. if (i > n) {
  22. for (int j = 1; j <= n; ++j) {
  23. cout << bin[j];
  24. }
  25. cout << endl;
  26. return;
  27. }
  28.  
  29. bin[i] = 0;
  30. Try(i + 1);
  31.  
  32. bin[i] = 1;
  33. Try(i + 1);
  34. }
  35.  
  36. int32_t main() {
  37. ios::sync_with_stdio(false);
  38. cin.tie(nullptr);
  39. cout.tie(nullptr);
  40.  
  41. if (fopen(NAME".INP", "r")) {
  42. freopen(NAME".INP", "r", stdin);
  43. freopen(NAME".OUT", "w", stdout);
  44. }
  45.  
  46. cin >> n;
  47. Try(1);
  48.  
  49. return 0;
  50. }
  51.  
Success #stdin #stdout 0s 5308KB
stdin
Standard input is empty
stdout