#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;
int x,cnt,flag;
queue<int>qu;
int low(int x)
{
int cnt=0;
int out=-1;
while(x)
{
if(!(x&1))out=cnt;
cnt++;
x>>=1;
}
if(out==-1)return -1;
return out+1;
}
int main()
{
scanf("%d",&x);
while(1)
{
int ans=low(x);
if(ans==-1) break;
if(flag)x++,flag=0,cnt++;
else
{
int res=pow(2,ans)-1;x^=res;qu.push(ans);flag=1;
cnt++;
}
}
printf("%d\n",cnt);
while(!qu.empty())
{
cout<<qu.front()<<" ";
qu.pop();
}
return 0;
}
Codeforces Round #554 (Div. 2) B
猜你喜欢
转载自blog.csdn.net/wzazzy/article/details/89680060
今日推荐
周排行