这个代码怎么过的
查看原帖
这个代码怎么过的
664744
_lqs_楼主2023/7/5 09:29
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,ans,t;
int qpow(int a,int b){
	int res=1;
	while(b){
		if(b&1) res=res*a;
		b>>=1;
		a=a*a;
	} 
	return res;
}
signed main(){
	scanf("%lld",&t);
	while(t--){
		scanf("%lld",&n);
		ans=(long long)log2(n)+2;
		if(n-qpow(2,(long long)log2(n))>qpow(2,((long long)log2(n))+1LL)-n) ans++;
		printf("%lld\n",ans);
	}
	return 0;
}

有正确性吗

2023/7/5 09:29
加载中...