fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define LCM(a,b) (a / __gcd(a,b) ) *b
  5. #define GCD(a,b) __gcd(a,b)
  6. #define SQR(a) ((a)*(a))
  7. #define pb push_back
  8. #define mk make_pair
  9. #define ff first
  10. #define ss second
  11. #define all(a) a.begin(),a.end()
  12. #define lastEle(v) v[v.size()-1]
  13. #define ABS(x) ((x)<0?-(x):(x))
  14. #define min3(a,b,c) min(a,min(b,c))
  15. #define min4(a,b,c,d) min(a,min(b,min(c,d)))
  16. #define max3(a,b,c) max(a,max(b,c))
  17. #define max4(a,b,c,d) max(a,max(b,max(c,d)))
  18. #define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
  19. #define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
  20. #define MEM(a,x) memset(a,x,sizeof(a))
  21. #define Godspeed ios_base::sync_with_stdio(0);cin.tie(NULL)
  22. #define urs(r...) typename decay<decltype(r)>::type
  23. #define FOR(i,a,b) for(urs(b) i=a;i<=b;i++)
  24. #define ROF(i,a,b) for(urs(b) i=a;i>=b;i--)
  25. #define REP(i,b) for(urs(b) i=0;i<b;i++)
  26. #define PER(i,a,b) for(urs(b) i=a;i>b;i--)
  27. #define FOREACH(i,t) for (__typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
  28. #define PRESENT(c,x) ((c).find(x) != (c).end())
  29. #define CPRESENT(c,x) (find(all(c),x) != (c).end())
  30. #define SPRESENT(c,x) ((c).find(x) != string::npos)
  31. #define Bye return 0
  32. #define ODD(x) (bool)(x&1)
  33. #define Debug cout<<endl<<"I AM BATMAN"<<endl;
  34. #define what_is(x) cerr << __LINE__ <<": " << #x << " is " << x << endl;
  35. //Datatypes
  36. #define ll long long
  37. #define ULL unsigned long long
  38. #define LD long double
  39. #define UI unsigned int
  40. #define US unsigned short
  41. #define endl '\n'
  42. const long long int MOD = 1000000007; // 998244353
  43. const ll INF = 1e18;
  44. const ll inf = 0xFFFFFFFFFFFFFFFL;
  45. #define PI acos(-1.0)
  46.  
  47. bool sortbysec(const pair<long long int,long long int> &a, const pair<long long int,long long int> &b)
  48. {
  49. return (a.second < b.second);
  50. }
  51.  
  52. //Debugging stuff
  53. #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
  54. void err(istream_iterator<string> it) {}
  55. template<typename T, typename... Args>
  56. void err(istream_iterator<string> it, T a, Args... args)
  57. {
  58. cerr << *it << " = " << a << endl;
  59. err(++it, args...);
  60. }
  61. #define pii pair<int,int>
  62. #define pll pair<long long,long long>
  63. #define pdd pair<double,double>
  64. #define pldld pair<long double, long double>
  65.  
  66. /*
  67.   Syed Rifat Raiyan
  68.   IUT CSE-18
  69.   Beautifully struggle every day~
  70. */
  71.  
  72. int main()
  73. {
  74. Godspeed;
  75. int Tests=1;
  76. //cin>>Tests;
  77. while(Tests--)
  78. {
  79. ll n;
  80. cin>>n;
  81. vector<string>b;
  82. queue<string>q;
  83. q.push("1");
  84. REP(i,n)
  85. {
  86. string s=q.front();
  87. q.pop();
  88. b.pb(s);
  89. string t=s;
  90. s+="0";
  91. q.push(s);
  92. t+="1";
  93. q.push(t);
  94. }
  95. REP(i,n)
  96. {
  97. cout<<b[i]<<" ";
  98. }
  99. }
  100. Bye;
  101. }
  102.  
  103.  
  104.  
  105.  
  106.  
Success #stdin #stdout 0.01s 5408KB
stdin
16
stdout
1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111 10000