代码:(有些奇奇怪怪的东西)
#include<bits/stdc++.h>
using namespace std;
// #define fileio
#define IOS
void ___()
{
#ifdef fileio
freopen(".in","r",stdin);
freopen(".out","w",stdout);
#endif
#ifdef IOS
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define endl '\n'
#endif
}
#define ll long long
typedef unsigned int uint;
uint solve(uint x)
{
uint t=x,p=0,y=0;
bool f=0;
if((t&1)==0)
t>>=1,p++,f=1;
while(t)
{
if((t&1)==0)
break;
y&=((t&1)<<p);
p++;
t>>=1;
}
return (t<<p)&(y<<(1+f));
}
int main()
{
___();
while(1)
{
uint x;
cin>>x;
if(!x)
break;
cout<<solve(x)<<endl;
}
return 0;
}
思路:找到不在第 0 位(即最低位)的最低位的 0,然后把这个 0 后面的部分右移一位。但是全输出 0,dalao 求调