60pts求hack
查看原帖
60pts求hack
482856
TigerNick楼主2023/7/21 17:20
#include <bits/stdc++.h>
#define int ull
#define LL ull
#define ull unsigned long long
int T,b[70];
LL a;
using namespace std;
int popcount(LL x)
{
    int s=0,k=0,l=0;LL t=x;
    while(x)
    {
        x&=x-1;
        s++;
    }
    x=t;
    while(x)
    {
        if(x&1) b[++l]=k;
        ++k;
        x>>=1;
    }
    return s;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin>>T;
    while(T--)
    {
        memset(b,0,sizeof(b));
        cin>>a;
        int c=popcount(a);
        if(c>=3) cout<<"No,Commander"<<'\n';
        else
        {
            if(a&1) cout<<a+1<<'\n';
            else
            {
                if(c==1) cout<<a+1<<'\n';
                else if(!a) cout<<1<<'\n';
                else if(b[1]+1==b[2]) cout<<(1<<(b[2]+1))<<'\n';
                else cout<<(1<<b[2])+(1<<(b[1]+1))<<'\n';
            }
        }
    }
    return 0;
}

60pts,实在不理解错哪了

2023/7/21 17:20
加载中...