站外题求助
  • 板块题目总版
  • 楼主jqQt0220
  • 当前回复6
  • 已保存回复6
  • 发布时间2023/11/22 21:40
  • 上次更新2023/11/23 09:16:24
查看原帖
站外题求助
678175
jqQt0220楼主2023/11/22 21:40

link

代码:(有些奇奇怪怪的东西)

#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 求调

2023/11/22 21:40
加载中...