Advertisement
a53

Order

a53
Jan 6th, 2022
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. ifstream f("order.in");
  4. ofstream g("order.out");
  5. int q,c,n,s,x,st[100],top,cnt;
  6. long long sol;
  7.  
  8. int main()
  9. {
  10. f>>q;
  11. while(q--)
  12. {
  13. f>>c;
  14. if(c==1)
  15. {
  16. for(f>>n,sol=0,s=0;n;--n)
  17. f>>x,s+=x,sol<<=x,--x,sol|=((1LL<<x)-1);
  18. sol|=(1LL<<(--s));
  19. g<<sol<<'\n';
  20. }
  21. else
  22. {
  23. f>>sol;
  24. top=0;
  25. while(sol)
  26. {
  27. ++top;
  28. while(sol%2)
  29. ++st[top],sol/=2;
  30. ++st[top];
  31. sol/=2;
  32. }
  33. --st[top];
  34. g<<top<<' ';
  35. for(;top;--top)
  36. g<<st[top]<<' ',st[top]=0;
  37. g<<'\n';
  38. }
  39. }
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement