fork(6) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. inline void write(int x) { cout << x << ' '; }
  5.  
  6. void transform(int n, int mul) {
  7. write(mul);
  8. switch (n) {
  9. case 1:
  10. return;
  11. case 2:
  12. write(2*mul); return;
  13. case 3:
  14. write(mul), write(3*mul); return; }
  15. for (int q = (n-1)/2, i = 0; i < q; ++i)
  16. write(mul);
  17. transform(n/2,2*mul); }
  18.  
  19. int main() {
  20. int n;
  21. ios_base::sync_with_stdio(false), cin.tie(nullptr), cin >> n, transform(n,1); }
  22.  
Success #stdin #stdout 0s 4528KB
stdin
25
stdout
1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 4 4 4 8 8 24