这为什么TLE,时间复杂度算上T也才O(T logn),求大佬看看
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll T,k,n;
bool check(int x)
{
if(x%2) x+=1;
int t=0;
while(!t)
{
t+=(x&1);
x>>=1;
}
return x;
}
int main()
{
cin>>T;
while(T--)
{
cin>>k>>n;
if(n==0)
{
if(k>0) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
continue;
}
ll x=1,t=0;
while(x<n)
{
x<<=1;
t++;
}
ll y=x-n;
while(y)
{
t+=(y&1);
y>>=1;
}
if(k<t) cout<<"No"<<endl;
else if(k-t==3)
{
if(n==1) cout<<"No"<<endl;
else cout<<"Yes"<<endl;
}
else if(k-t==1)
{
if(check(n)) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
else cout<<"Yes"<<endl;
}
return 0;
}