求大佬证明我的思路 qwq
查看原帖
求大佬证明我的思路 qwq
554145
Night_sea_64楼主2023/12/25 20:04

我的 AC 代码如下:

#include<iostream>
using namespace std;
int ppc(long long x)
{
    int cnt=0;
    while(x)cnt+=x%2,x/=2;
    return cnt;
}
bool chk(long long k,long long cnt){
    return cnt<=k&&cnt>=ppc(k);
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        long long k,n;
        cin>>k>>n;
        bool flag=0;
        for(long long i=1,tmp=0;i<=4e18&&tmp<=k;i*=2,tmp++)
        {
            if(i>=n&&chk(i-n,k-tmp))
            {
                flag=1;
                break;
            }
        }
        if(flag)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

我枚举的 tmptmp 是 ×2\times2 的次数,但是在上面代码中这个次数显然 <63<63。有没有大佬证明这是对的或者给出 hack?谢谢!

2023/12/25 20:04
加载中...