P10026 求hack
  • 板块灌水区
  • 楼主_Icetihw_
  • 当前回复2
  • 已保存回复2
  • 发布时间2023/12/24 22:11
  • 上次更新2023/12/25 13:44:57
查看原帖
P10026 求hack
1127667
_Icetihw_楼主2023/12/24 22:11
#include<bits/stdc++.h>
#define ll unsigned long long
using namespace std;
ll t,n,k;
ll get(ll x){
	if(x == 1)return 0;
	ll cnt = 0,ans = 0;
	while(x){
		++cnt;
		if(!(x % 2)) ans++;
		x >>= 1;
	}
	return ans + cnt + 1;
}
ll gets(ll x){
	ll ans = 0;
	while(x%2 == 0){
		ans++;
		x >>= 1;
	}
	ans += get(x);
	return ans;
}
ll log2(ll x){
	return (ll)(log(x) / log(2));
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>t;
	while(t--){
		cin>>k>>n;
		ll ans = gets(n);
		if(ans > k || (n == 1 && k == 3)) cout<<"No"<<endl;
		else if(((ll)(log2(n)) == log2(n) || (ll)(log2(n+1)) == log2(n+1)) && ans + 1 == k) cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}
	return 0;
}

违规自删

2023/12/24 22:11
加载中...