Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define test int tt; cin>>tt; for(int cs=1;cs<=tt;cs++)
- int main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- vector<ll>x;
- ll n,m,i,j,k,l=1;
- for(i=1; i<=60; i++)
- {
- l*=2;
- x.push_back(l-1);
- }
- test
- {
- ll n,m,i,j,k=0,l=1;
- vector<ll>ans;
- cin>>n;
- if(n==0)
- {
- cout<<2<<endl;
- cout<<"1 1"<<endl;
- continue;
- }
- ll e=0;
- while(n>0)
- {
- for(i=0; i<x.size(); i++)
- {
- if(x[i]>=n)
- {
- ans.push_back(x[i]);
- n=x[i]-n;
- break;
- }
- }
- }
- sort(ans.begin(),ans.end());
- cout<<ans.size()<<endl;
- for(auto d:ans)
- {
- cout<<d<<" ";
- }
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment